This PR updates the Jest migration so it handles both CJS and ESM format
for Jest config file. We now generate with ESM so those need to be
handled. There are four combinations:
1. `require` (CJS) with `module.export` (CJS)
2. `import` (ESM) with `export default` (ESM)
3. `require` (CJS) with `export default` (ESM)
4. `import` (ESM) with `module.export` (CJS)
(1) and (2) should cover almost all cases, and (3) and (4) are there
just in case. If the format isn't matching what we generate, then just
bail.
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->
## Current Behavior
<!-- This is the behavior we have today -->
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes #
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->
## Current Behavior
<!-- This is the behavior we have today -->
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes #
<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->
<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->
<!-- If this is a particularly complex change or feature addition, you
can request a dedicated Nx release for this pull request branch. Mention
someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they
will confirm if the PR warrants its own release for testing purposes,
and generate it for you if appropriate. -->
## Current Behavior
<!-- This is the behavior we have today -->
## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->
## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->
Fixes #
* feat(testing): support jest 28
WIP jest migration
* fix(testing): jest-environment-jsdom must be explicitly added now
* fix(testing): add rxjs to the transform lsit
* fix(testing): jest ts-jest updates and resolver issues
* feat(testing): remove test runner for react native jest
* feat(testing): add preprocessor for react native jest
* fix(testing): update query to handle tsx file syntax, remove rxjs transform
* chore(repo): remove file from accident commit
* chore(testing): update migration to target 14.6 for RN jest preprocessor
* fix(testing): call passed in packageFilter if preset
* docs(testing): add resolver env var to troubleshooting guide
* chore(repo): prep resolver for jest 28 migration
* fix(testing): update deps to handle esbuild-wasm service error
* fix(testing): switch to testEnvironmentOptions for cjs loading vs resolver list
* fix(testing): force babel-jest preset in transformer for project transforms
* chore(testing): address PR feedback
* fix(testing): address pr feedback, remove react-native transform
* chore(testing): update createTreeWithEmptyWorkspace calls
* chore(testing): address pr feedback
* feat(testing): add migration script for react native to rename .babelrc to babel.config.json
* chore(testing): nx format after rebase
* chore(testing): fix display name for @nrwl/js
Co-authored-by: Emily Xiong <xiongemi@gmail.com>
* feat(devkit): split create-empty-tree to different functions
* chore(repo): apply migration for createEmptyTree
* cleanup(misc): fix tests that migration misses
* fix(testing): jest.preset.ts => jest.preset.js
* fix(testing): update to export default
* fix(testing): migration for moving to export default
* fix(testing): add eslint ignore comments for jest config properties
fixes: #10021
* fix(testing): update tsconfig.spec.json for next apps with project parserOptions
fixes: #9982
* fix(testing): prevent renaming root jest preset
fixes: #9973
* fix(testing): update snapshots for export default
* fix(testing): bump migration version to run
* fix(testing): make sure default jest tests pass for various projects
* fix(js): generate correct jest config for --compiler=swc --js
* feat(testing): move jest config to .ts
move jest config and preset to ts files
ISSUES CLOSED: #8344
* fix(testing): update tests for jest.config.ts changes
update tests broken by renaming jest fils to ts files
Fix issue for migrating jest plugin to 13.4.4 when the projects
may have a custom preset that
excludes the transform property
from the jest.config.js.
Just adds an if statement around the
loop for the transform property
ISSUES CLOSED: #8566
* fix(testing): create root babel config for babel-jest option
when creating a jest project with babel-jest a root babel.config.json file will be create if one
doesn't exist and babel deps install for allowing jest tests to run successfully
ISSUES CLOSED: #6782
* feat(testing): add migration for missing root babel config
* fix(testing): update tsconfig migration to not warn when no file found
use tsconfig.json references to find what other configs need to be updated. if non when we just exit
* fix(testing): update tests for migration changes
* fix(testing): include any spec. file names in pattern match
accounting for _spec. file names when generating 'test' pattern equivalents
* fix(testing): remove relance on tsconfig.references, walk for all tsconfigs to update
tsconfig.references is not always present. instead visit all files and check if they are tsconfig
json file. if so we update the include/exclude properties where a spec. pattern is found. if the
property isn't set then we do not update it.
* fix(testing): stream line update with devkit
* fix(testing): add .test. files to spec tsconfig template
add support for .test.ts and with supportTsx .test.{js|tsx|jsx} files
in the tsconfig.spec.json template.
Note each package that excludes testing files will need to be updated to
exclude the new files (coming in future commits)
* fix(angular): add .test.ts support in tsconfigs
add .test.ts in angular jest template
update angular generators to exclude test files
* fix(gatsby): add .test. file prefixes to tsconfig ignore
ignore the new .test.{js|ts|jsx|tsx} files added to jest configs
* fix(react): add .test. file prefix to app/lib tsconfigs
add .test.{ts|js|tsx|jsx} files to be excluded by app/lib tsconfig
* fix(node): add .test. file prefix to app/lib tsconfig
add .test.{ts|js|tsx|jsx} files to be excluded by app/lib tsconfig
ISSUES CLOSED: #7263
* fix(nest): update tests for new .test.ts files in tsconfig
update tests to account for changes in node generators which add .test.ts to the exclude of
tsconfigs
* fix(express): update tests to account for new tsconfig changes
updated snapshots
added new patterns for tsconfig
* fix(linter): update snapshots for new tsconfig changes
snapshot updated to include new .test.ts file changes for tsconfig
* fix(node): update testing to account for spec tsconfig changes
add .test.ts files in e2e tests
* fix(testing): add migration for tsconfig changes
initial migration and test for tsconfig changes
* chore(testing): add to migrations collection
add the update-ts-config-for-test-filenames to migrations
* fix(testing): fix filesystem issue with jest tests
mock readConfig to always return an basic config to prevent issues of not finding a config in non
linux environments, aka missing /root
* cleanup(testing): update error message
update message logged when tsconfig isn't found to mention what was trying to be accompished so it
can be manually updated if desired.