bahmutov / bahmutov/cypress-split
`Webpack Compilation Error` when using `paths` aliases in Typescript (running `empty-4-of-4.cy.js` spec)
- Dominant language
- JavaScript
- Stars
- 285
- Forks
- 28
- PR merge metrics
- No merged PRs in 30d
Description
Hi @bahmutov, thank you very much for this project!
Could you please suggest how to make `cypress-split` work when using `paths` aliases in `tsconfig`?
i.e. given the `/cypress/tsconfig.json`:
```json
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@testing-library/cypress", "node"],
"baseUrl": "./",
"paths": {
"#/*": ["../src/*"],
"#tests/*": ["../tests/*"]
}
},
"include": ["**/*.ts"]
}
```
setting up running the `cypress-split` per readme, when having only 3 spec files:
(running on local Mac OS machine)
```
# errors out with
# Error: Webpack Compilation Error
# Module not found: Error: Can't resolve '#tests/mock-rest-api-server' in '/Users/…/…/…/…/…/cypress/support'
# …
# The spec file that runs is `empty-4-of-4.cy.js`
SPLIT=4 SPLIT_INDEX=3 yarn cypress run
```
and running the following succeds:
```
# runs succesfully
# The spec file that runs is `notifications.cy.ts`
SPLIT=4 SPLIT_INDEX=1 yarn cypress run
```
---
Additional info:
- If I change the source code of `node_modules/cypress-split/src/index.js` to use `empty-spec.cy.ts` and run `SPLIT=4 SPLIT_INDEX=3 yarn cypress run` again, I get more info on the error:
```
Running: empty-4-of-4.cy.ts (1 of 1)
Oops...we found an error preparing this test file:
> ../../../../../../var/folders/p0/npm2s71j2bz2s8pm770p55700000gp/T/empty-4-of-4.cy.ts
The error was:
Error: Webpack Compilation Error
[tsl] ERROR
TS18002: The 'files' list in config file 'tsconfig.json' is empty.
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with cypress/tsconfig.json and the Cypress run commands shown in the report, then inspect node_modules/cypress-split/src/index.js and the empty-4-of-4.cy.js or empty-spec.cy.ts path. Reproduce the Webpack compilation error for SPLIT=4 and compare it with the successful notifications.cy.ts run; done means the aliased imports and the affected split spec compile and run successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cypress, javascript, typescript, webpack
- Domain
- testing, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100