`data-testid` being stripped in test/local env in latest 12.1.6
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System: Platform: linux Arch: x64 Version: #1 SMP Wed Mar 2 00:30:59 UTC 2022 Binaries: Node: 14.18.1 npm: 6.14.15 Yarn: 1.22.18 pnpm: N/A Relevant packages: next: 12.1.6 react: 18.1.0 react-dom: 18.1.0
What browser are you using? (if relevant)
Firefox
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
In the latest 12.1.6, running Jest locally with tests that try to locate elements using the data-testid
attr fail, this works fine in 12.1.5.
In my next config I have:
compiler: {
styledComponents: true,
reactRemoveProperties: true,
},
Expected Behavior
data-testid
should only be removed in production env, not local or preview envs.
To Reproduce
Create a projec with latest next, jest, and a test that looks for a data-testid
.
Issue Analytics
- State:
- Created a year ago
- Reactions:4
- Comments:6 (2 by maintainers)
Top Results From Across the Web
babel-plugin-jsx-remove-data-test-id
babel plugin to remove data-test-id attributes. Latest version: 3.0.0, last published: 2 years ago.
Read more >Untitled
Paris torosidis tennis, Pre anesthesia testing, Optica planeta vision, Einhell hebezug, ... New balloon designs, Traktory dojc, Local weather 76401, ...
Read more >Search Results - CVE
The mission of the CVE® Program is to identify, define, and catalog publicly disclosed cybersecurity vulnerabilities.
Read more >Lead acetate | C4H6O4Pb - PubChem - NIH
National Toxicology Program, Institute of Environmental Health Sciences, ... Hazardous Substances Data Bank (HSDB); ILO International Chemical Safety Cards ...
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 FreeTop 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
Top GitHub Comments
The issue should be fixed by https://github.com/vercel/next.js/pull/36922
In the meantime, you can apply a temporary fix in your
next.config.js
:This is because
next/jest
previously did not apply the opt-in transforms and that was fixed. I guess forreactRemoveProperties
we’ll want to disable that in the test env when thetrue
option is used.