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

>1.2.4 act(...) is not supported in production builds of React #467

Closed
4 tasks done
zthun opened this issue Sep 8, 2024 · 2 comments
Closed
4 tasks done

>1.2.4 act(...) is not supported in production builds of React #467

zthun opened this issue Sep 8, 2024 · 2 comments

Comments

@zthun
Copy link

zthun commented Sep 8, 2024

Describe the bug

Running tests in vscode with version >= 1.2.4 of the plugin in a react environment with @testing-library/react runs seems to be using an incorrect environment.

This causes an error on the following invocation:

import { render } from '@testing-library/react';

const createTestTarget = () => {
    // Fails with error
    const result = render(<MyComponent />);
}

act(...) is not supported in production builds of React

Reverting back to 1.2.3 solves this problem.

Reproduction

https://github.com/zthun/cirque

git clone https://github.com/zthun/cirque
cd cirque
yarn install
# Works Just fine
yarn test
  1. Navigate vscode to packages/cirque-react/src/tod/checklist/checklist.spec.tsx
  2. Click Run Tests

image

Output

[INFO 2:34:33 PM] Running 1 file(s) with name pattern: ^\s?ZChecklist
[2:34:33 PM] The runner is starting because tests /Users/zthun/Development/cirque/packages/cirque-react/src/todo/checklist/checklist.spec.tsx were started due to a file change
[2:34:33 PM] Enqueuing "ZChecklist
[2:34:33 PM] Enqueuing "should start as empty
[2:34:33 PM] Enqueuing "Adding items
[2:34:33 PM] Enqueuing "should add an item.
[2:34:33 PM] Enqueuing "should add new items to the end of the list
[2:34:34 PM] No task result for "should start as empty", assuming the test just started running
[2:34:34 PM] No task result for "should add an item.", assuming the test just started running
[2:34:34 PM] No task result for "should add new items to the end of the list", assuming the test just started running
[2:34:34 PM] No errors found for "[@zthun/cirque-react] checklist.spec.tsx"
[2:34:34 PM] No errors found for "ZChecklist"
[2:34:34 PM] Marking "should start as empty" as failed with 1 errors
[2:34:34 PM] No errors found for "Adding items"
[2:34:34 PM] Marking "should add an item." as failed with 1 errors
[2:34:34 PM] Marking "should add new items to the end of the list" as failed with 1 errors
[2:34:34 PM] No errors found for "[@zthun/cirque-react] checklist.spec.tsx"
[2:34:34 PM] Ending test run packages/cirque-react/src/todo/checklist/checklist.spec.tsx

Version

1.2.5

Validations

@zthun
Copy link
Author

zthun commented Sep 8, 2024

I'm pretty sure the cause of this change was this:

v1.2.3...v1.2.4

define: {
  // The default here now defaults to production instead of dev
  'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
},

@sheremet-va
Copy link
Member

Fixed in 6ab9dfe

@github-actions github-actions bot locked and limited conversation to collaborators Sep 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants