Generate a data-access library under an existing directory completes successfully. After this running jest tests errors out on any of the libs with
(oldOptions[key] || []).map is not a function
The tests should run successfully.
Write some lib tests that pass for all libs
yarn nx run-many --target=test --all
Create a new library by running this command:
nx generate @nrwl/react:library --name=data-access --directory=ui/main --no-component --tags='scope:ui-main, type:data-access'
Run tests again
(oldOptions[key] || []).map is not a function
nx : 10.3.0
@nrwl/angular : Not Found
@nrwl/cli : 10.3.0
@nrwl/cypress : 10.3.0
@nrwl/eslint-plugin-nx : 10.3.0
@nrwl/express : 10.3.0
@nrwl/jest : 10.3.0
@nrwl/linter : 10.3.0
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : 10.3.0
@nrwl/react : 10.3.0
@nrwl/schematics : Not Found
@nrwl/tao : 10.3.0
@nrwl/web : 10.3.0
@nrwl/workspace : 10.3.0
typescript : 4.0.3
Downgrading back to 10.2.1 fixes the problem.
One difference i noticed is in the lib's jest.config.js
module.exports = {
...
preset: "../../../../jest.config.js", // <-- this value is ../../../../jest.preset.js in 10.3.0
...
};
I experience the same issue after upgrading to 10.3.0.
In my case, it was after adding a new node library which seems to me not at all to be related to React but libraries in general. nx g @nrwl/node:library now-version.
What I noticed is the jest.config.js in the root folder had an additional property added to it that seemed to lock Jest to a specific project. Therefore only the newly added project was testable.
Removing the file, allowed all tests from all projects to function again.
module.exports = {
...
passWithNoTests: true,
projects: '<rootDir>/libs/now-version' // <--- newly added property. should be removed
};
This is still an issue in 10.3.1
@tmakola thank you for the comment above - I can confirm your fix restores testing functionality for us.
I can confirm that this is not react specific and happened to me on a node library as well. @tmakola's trick solved it for me, too!
@tmakola thank you, too! Saved me a lot of time.
@maierson @Mobiletainment can you please elaborate on the steps to reproduce it? I have tried both the latest and 10.3.0 and wasn't able to do so 馃
@bekos Just the steps at the top of this thread. I started with nx when it was at version 8... and kept migrating up. I think the migration process might not have handled this properly at some point in the process which might be why this is happening. Do you have a jest.config.js at the root of your project? And does it have a "projects" key in it?
Most helpful comment
I experience the same issue after upgrading to 10.3.0.
In my case, it was after adding a new node library which seems to me not at all to be related to React but libraries in general.
nx g @nrwl/node:library now-version.What I noticed is the
jest.config.jsin the root folder had an additional property added to it that seemed to lock Jest to a specific project. Therefore only the newly added project was testable.Removing the file, allowed all tests from all projects to function again.