Closed aspergillusOryzae closed 3 years ago
Experienced the same issue after updating to 12.6.3
Thanks for reporting this!
I'm not able to reproduce this in a fresh workspace using a previous version. It would seem that there might be something in the jest.config.js
configuration you have that the migration doesn't expect.
Could you please share your jest.config.js
file content? Or better yet, would you be able to provide a minimal repo where the issue can be reproduced?
Hi, thanks for replying!
Here is the content of my jest.config.js already:
module.exports = { testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'], transform: { '^.+\\.(ts|js|html)$': 'ts-jest', }, resolver: '@nrwl/jest/plugins/resolver', moduleFileExtensions: ['ts', 'js', 'html'], coverageReporters: ['html'], testEnvironment: 'jsdom', };
I will also try to setup a small repo, but it may take some time to recrate the exact configuration.
Could it also be a Windows problem again? I guess most people are working on a Unix system, but I'm "still" on Windows 10.
Is that the jest.config.js
at the root of the workspace?
If that's the case, the issue is happening because the migration is expecting it to have a projects
property, which is what gets generated by default in Nx workspaces. That said, we can/should handle root configs without that property to avoid the migration to fail.
It is at the root of the workspace (same place as the workspace.json). However it is not at the root of the GitHub repository but in a subfolder called "web" for historical reasons. Can I just add the projects property?
Yes, you can either add projects: []
before running the migration (recommended), or just remove the update-jest-config-to-use-util
migration from the migrations.json
file if you prefer to keep your root config as it is now.
Ok, cool! Will give it a try soon.
The migration went through now! The only thing is after the successful migration my production build is now failing :-)
nx run navigator:build:production
webpack.WebpackError is not a constructor
But that is probably not to be discussed here
Yeah, that'd be a different issue.
This is my jest.config.js
contents:
module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
};
It is located at the root of my workspace, alongside package.json
and migrations.json
.
I also have two libs
directories with the following jest.config.js
contents at the parent level of each:
module.exports = {
name: '<lib-name>',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/libs/<lib-name>',
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
module.exports = {
name: '<lib-name1>',
preset: '../../jest.config.js',
coverageDirectory: '../../coverage/libs/<lib-name1>',
snapshotSerializers: [
'jest-preset-angular/build/serializers/no-ng-attributes',
'jest-preset-angular/build/serializers/ng-snapshot',
'jest-preset-angular/build/serializers/html-comment',
],
};
@aspergillusOryzae I'll be pushing a fix for this issue soon. In the meantime, you can read this comment where a workaround was provided.
I'll give that a try, thanks!
I tried with the latest 12.6.4 and not adding projects: []
to my jest.config.js
, but got the same error as before.
When I added projects: []
to the parent jest.config.js
the migration completed successfully. I did not need to modify my libs/<lib-name>/jest.config.js
files (in case anyone else is in a similar situation).
Post-migration the parent jest.config.js
looks like:
module.exports = {
testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
transform: {
'^.+\\.(ts|js|html)$': 'ts-jest',
},
resolver: '@nrwl/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html'],
coverageReporters: ['html'],
projects: getJestProjects(),
};
@aspergillusOryzae the fix is in master now but it hasn't been released yet, it will be included in the next patch release.
This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.
Current Behavior
Migration failure
nx migrate --run-migrations=migrations.json --verbose
fails with (absolute paths removed):Expected Behavior
Successful migration
Steps to Reproduce
This is my first time using
nx migrate
, but if I takeupdate-jest-config-to-use-util
out ofmigrations.json
it succeeds.Failure Logs
Included in current behavior section above.
Environment
> npx nx report
> NX Report complete - copy this into the issue template
Node : 12.16.3 OS : darwin x64 yarn : 1.22.4
nx : Not Found @nrwl/angular : 12.6.3 @nrwl/cli : 12.6.3 @nrwl/cypress : 12.6.3 @nrwl/devkit : 12.6.3 @nrwl/eslint-plugin-nx : Not Found @nrwl/express : Not Found @nrwl/jest : 12.6.3 @nrwl/linter : 12.6.3 @nrwl/nest : Not Found @nrwl/next : Not Found @nrwl/node : Not Found @nrwl/nx-cloud : Not Found @nrwl/react : Not Found @nrwl/schematics : Not Found @nrwl/tao : 12.6.3 @nrwl/web : Not Found @nrwl/workspace : 12.6.3 @nrwl/storybook : 12.6.3 @nrwl/gatsby : Not Found typescript : 4.3.5
From the
migration.json
file: