Repository navigation
Conversation
This commit does not have test runner support, only works for running `cd test/jest-esm; npm run jest`.
Previous changes introduced a change in command-line arg processing.
The previous bug is that --max-workers should not be set when --runInBand is used.
Author
|
I added logging to help if |
3 tasks done
3 tasks done
Member
|
@johncrim thanks for raising the PR and supporting Stencil. The team has decided not to move forward with this. We are planning to build a Jest preset for Jest v30 and up that will be published as a standalone module e.g. Again, thanks a lot for everything! |
Author
|
Thanks for the update @christian-bromann . As long as ESM is handled well, I'm happy. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note up front: I don't believe this is quite ready to merge, open issues/questions noted below. I'm posting this PR for initial review/evaluation.
Pull request checklist
Please check if your PR fulfills the following requirements:
npm run build) was run locally and any changes were pushednpm test) were run locally and passednpm run test.karma.prod) were run locally and passednpm run prettier) was run locally and passedPull request type
Please check the type of change your PR introduces:
What is the current behavior?
GitHub Issue Number: #3230
What is the new behavior?
Jest tests are run using ES modules if the following changes are made:
--experimental-vm-modules, e.g.node --experimental-vm-modules node_modules/jest/bin/jest.jsorNODE_OPTIONS=--experimental-vm-modules npx jestetc.I also like to include
--no-warningsto eliminate the experimental feature warning on startup.testing.useESModules: trueAlternatively, if jest is run directly (not through the stencil CLI), the following
jest.config.cjscan be used to run stencil tests using ES modules:In addition, a bug is fixed: If
--runInBandis passed in the CLI,--max-workers=${config.maxConcurrentWorkers}is no longer set. I had to fix this in order to debug my work on this feature. The behavior was incorrect before (one of--runInBandor--max-workerswins, b/c--runInBandmeans no external worker processes), and I added tests to validate it.I can break that out if you really want me to...
Does this introduce a breaking change?
Changes should not be breaking - the previous code paths are effectively unchanged, so Jest tests using CJS continue to run as before.
Testing
I added some new unit tests, which only validate the config generation. I also added a new test sub-project
test/jest-esm. To run it:I didn't see a way to loop this project into the CI build; eg the
test/jest-spec-runnerisn't called in the github workflow.Open issues
Documentation. I added js docs to the new config values, but that's probably not sufficient. I didn't see an obvious place to add docs.
More tests would be nice - eg running some jest + jest ESM tests through the whole stack, but I didn't see a pattern to follow.
Jest expect extensions are currently borken when using ESM and
@jest/globals. That's why there's this ugly expect:TLDR: The return type of
@jest/globals expect()is not the same asjest.JestMatchers<T>. So anyone using Jest ESM with expect extensions will have to work around the typing issue until this issue is fixed. Note that this applies to anyone using Jest ESM, it is not stencil specific, but stencil developers likely use expect extensions.I think the last issue is tolerable (and looks like it should be fixed soon) - since this is opt-in, I think it's reasonable to provide this as a preview feature while Jest improves their ESM support.
Other
I validated that these changes provide a fix for #3251, if projects affected by #3251 are willing to switch to using ES modules while testing. Since #3251 only appears due to ESM dependencies, I would think this would be attractive.