Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(react-native): update generated jest config to be in sync w/cache #18366

Merged
merged 1 commit into from
Jul 28, 2023

Conversation

barbados-clemens
Copy link
Contributor

Current Behavior

Jest config generates coverage reports in the project root, which does not match executor outputs nor the other existing project outputs

jest config doesn't transform common deps

Expected Behavior

jest config is updated to support the above 2

Related Issue(s)

Fixes #

@barbados-clemens barbados-clemens added scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx scope: react-native Issues relating to React Native labels Jul 28, 2023
@barbados-clemens barbados-clemens self-assigned this Jul 28, 2023
@barbados-clemens barbados-clemens requested a review from a team as a code owner July 28, 2023 14:17
@vercel
Copy link

vercel bot commented Jul 28, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nx-dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 28, 2023 3:21pm

@@ -32,9 +32,13 @@ export async function addJest(
resolver: '@nx/jest/plugins/resolver',
moduleFileExtensions: ['ts', 'js', 'html', 'tsx', 'jsx'],
setupFilesAfterEnv: ['<rootDir>/test-setup.${js ? 'js' : 'ts'}'],
transformIgnorePatterns: ['node_modules/(?!react-native|jest-runner)/'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

by default, react native jest preset already has a transformIgnorePatterns like:
https://github.com/facebook/react-native/blob/main/packages/react-native/jest-preset.js#L24
'node_modules/(?!((jest-)?react-native|@react-native(-community)?)/)',
is this still needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case probably not. I assume it's just extra deps that were added that ended up needing the patterns without realize it. I'll remove. 👍

Copy link

@AlaaInflyter AlaaInflyter Aug 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barbados-clemens Oups, i'm a bit late !
This is still needed apparently.
Easy to reproduce: create a bare project, add lib, launch tests, and you'll get something like

Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

Add the transformIgnorePatterns and the test passes.
If the preset adds it by default, it seems like it gets overridden somewhere hmm

@github-actions
Copy link

github-actions bot commented Aug 7, 2023

This pull request has already been merged/closed. If you experience issues related to these changes, please open a new issue referencing this pull request.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
scope: react-native Issues relating to React Native scope: testing tools Issues related to Cypress / Jest / Playwright / Vitest support in Nx
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants