Skip to content

data-testid being stripped in test/local env in latest 12.1.6 #36651

@wadehammes

Description

@wadehammes

Verify 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,
  },

image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TestingRelated to testing with Next.js.good first issueEasy to fix issues, good for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions