You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(jest): add internal support for jest 27 (#3171)
this commit adds support for stencil to run jest 27 for its own unit
tests. although it does not enable jest 27 for consumers of stencil, it
is the first step in the process that future work shall build upon.
update `jest`, `jest-cli` and `jest-environment-node` all to v27. jest
v27 switched many defaults that would otherwise break stencil tests. to
support jest v27:
- explicitly use the 'jest-jasmine2' test runner in our own internal
configuration. moving to 'jest-circus' will occur in STENCIL-307 and
is not on the critical path for supporting Jest 27
- create a `getVmContext` function in jest environment setup, a new
field that is required in v27
- remove unneeded `async` keyword from telemetry tests, which were
causing jest to fail
in addition to the changes above, several changes were required to be
made to our `jest-preprocessor`, which is used both by consumers of
stencil in addition to internal stencil tests:
Between Jest v23 (the latest when this file was originally authored) and
v27, the function signatures of `process` and `getCacheKey` have
changed, most ostensibly between v26 and v27. for the purposes of this
PR, we attempt to maintain backwards compatibility to the best of our
ability, which leads to extra type checking. it is expected that this be
removed in a future major version of Stencil.
the context of `this` has changed between v26 and v27 when code coverage
is generated for files that do not have tests associated with them. in
the original implementation, running jest with the '--coverage' flag
would cause a message to be printed to STDERR for _every file_ that
didn't have test coverage. To circumvent this, cached instances of
`tsconfig.json#options` and its stringified version have been hoisted to
no longer require being referenced through `this`.
an integer used to bust the Jest cache (previously just the number '6')
has been refactored out to a constant, `CACHE_BUSTER` with a JSDoc to
explain its usage and when it should be updated
finally, disable the tests that are responsible for invoking jest as a part of
the testing suite. the test assumes that jest can be run
programmatically, specifically that the program has programmatic access
to jest cli flags. with jest 27, this is no longer true. to limit the
scope of this work (which is planned in STENCIL-71), temporarily disable
the test. this is only necessary because stencil is internally running v27,
but end users are still using v26.
STENCIL-61: getCacheKey rework to support Jest 27
STENCIL-63: Jest 27 support for @stencil/core
0 commit comments