Generating react library causes tests to fail after upgrading to 10.3.0
See original GitHub issueCurrent Behavior
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
Expected Behavior
The tests should run successfully.
Steps to Reproduce
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
Failure Logs
(oldOptions[key] || []).map is not a function
Environment
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
...
};
Issue Analytics
- State:
- Created 3 years ago
- Reactions:4
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Test Utilities - React
ReactTestUtils makes it easy to test React components in the testing framework of your choice. At Facebook we use Jest for painless JavaScript...
Read more >Migration Guide | Cypress Documentation
Migrating to Cypress 12.0 This guide details the changes and how to change your code to migrate to Cypress version 12.0.
Read more >React Testing Library and the “not wrapped in act” Errors
I recently upgraded React and React testing library. ... When testing, code that causes React state updates should be wrapped into act(...): act(()...
Read more >react-native-device-info - npm
v6 to v7 upgrade. Your iOS Podfile will need to move to an iOS 10 minimum. v7 of this module no longer supports...
Read more >Bug listing with status RESOLVED with resolution OBSOLETE ...
... Bug:96449 - "New: fusd A library and kernel module to create userpsace char ... Bug:225283 - "sys-devel/automake-1.10.1 fails tests when active JVM...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.
Hi all - going back to my reproduction if you trace back through the commits, you can see that while I create a
migrations.json
file, I entered the command incorrectly as:nx migrate --run-migrations
Whereas prior versions (pre 11.4) required a target
migrations.json
file (so like so:nx migrate --run-migrations=migrations.json
).As such, these migrations were generated, but not ran. We’ve added more clarity around this in current versions - the cli prompts with
nx migrate --run-migrations=migrations.json
and we also now default tomigrations.json
if no explicit path is provided.To others having issues with this in their workspaces after migrating, you can rerun this migration specifically by creating a
migrations.json
with the contents:And then run
nx migrate --run-migrations=migrations.json
to correct your workspaces going forward.Also note that the
projects
property on your rootjest.config.json
exists to enable tooling with VsCode (and other IDEs) that allows your IDE to target and these tests correctly (see below). Removing theprojects
property from your rootjest.config.json
- or removing this file entirely - will allow your tests to be run via the nx CLI, but running jest tests via your IDE may break.