Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpack Compilation Error when using paths aliases in Typescript (running empty-4-of-4.cy.js spec) #105

Open
SergeyVolynkin opened this issue Oct 5, 2023 · 7 comments
Labels
question Further information is requested

Comments

@SergeyVolynkin
Copy link

SergeyVolynkin commented Oct 5, 2023

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:

{
  "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.
@SergeyVolynkin
Copy link
Author

SergeyVolynkin commented Oct 5, 2023

@bahmutov If I change the source code of node_modules/cypress-split/src/index.js to use '/Users/…/…/…/…/…/cypress/e2e' instead of os.tmpdir():

// node_modules/cypress-split/src/index.js

const tempFilename = path.join(
-  os.tmpdir(),
  `empty-${splitIndex + 1}-of-${splitN}.cy.js`,
)

const tempFilename = path.join(
+  '/Users/…/…/…/…/…/cypress/e2e', // i.e. placing the `empty-4-of-4.cy.js` where other cypress specs are located
    `empty-${splitIndex + 1}-of-${splitN}.cy.js`,
)

it solves the problem 🤔

@bahmutov
Copy link
Owner

bahmutov commented Oct 5, 2023

Ughh, to solve this, I would need a small repo with a reproducible example

@bahmutov bahmutov added the question Further information is requested label Oct 5, 2023
@SergeyVolynkin
Copy link
Author

SergeyVolynkin commented Oct 6, 2023

Absolutely! Will prepare a quick repo @bahmutov today (thank you for a quick response!)

@SergeyVolynkin
Copy link
Author

SergeyVolynkin commented Oct 6, 2023

Hi @bahmutov, extracted minimal reproducible example https://github.com/SergeyVolynkin/cypress-split-issue-105-ts-types#root-cause-analysis. Added root cause analysis into README.md

Please let me know what can be the fix in your code, I can open PR into https://github.com/bahmutov/cypress-split accordingly

@SergeyVolynkin
Copy link
Author

Will be on stand-by 🙂, @bahmutov

@bahmutov
Copy link
Owner

I would not be on stand by because I have a lot of other stuff to do. If you can please open a pull request with a fix instead.

@SergeyVolynkin
Copy link
Author

No worries, thank you @bahmutov! It's a very niche corner case where there are more runners than test files. Can be solved by manually creating empty(or TODO) spec files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants