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

[Bug]: conflicting expect extensions break jest-config #11977

Closed
blaky opened this issue Oct 18, 2021 · 2 comments · Fixed by #11978
Closed

[Bug]: conflicting expect extensions break jest-config #11977

blaky opened this issue Oct 18, 2021 · 2 comments · Fixed by #11978

Comments

@blaky
Copy link
Contributor

blaky commented Oct 18, 2021

Version

27.3.0

Steps to reproduce

In my project we are in the process of migrating tests from enzyme to testing-library, currently we have both of them in the project while we migrate the tests on a one-by-one basis. Both of these libraries define the toBeChecked (and many other duplicated expect extension). Before #11949 we were able to control which of these should take precedence by setting the order of imports. The PR mentioned above changed the code so it is now uses Object.defineProperty to add extensions to the expect object without the configurable property set.

Clone my repo: https://github.com/blaky/jest-issue
npm ci
npm test

The error you'll see:

 ● Test suite failed to run

    TypeError: Cannot redefine property: toBeChecked
        at Function.defineProperty (<anonymous>)

      at node_modules/expect/build/jestMatchersObject.js:103:14
          at Array.forEach (<anonymous>)

Expected behavior

Jest doesn't fail when loading expect extensions with conflicting names.

Actual behavior

Jest fails when loading expect extensions with conflicting names.

Additional context

No response

Environment

System:
    OS: macOS 11.5.1
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
  Binaries:
    Node: 14.17.4 - ~/.nvm/versions/node/v14.17.4/bin/node
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.4/bin/npm
  npmPackages:
    jest: ^27.3.0 => 27.3.0
@ybiquitous
Copy link

I also can reproduce this problematic behavior. Please see stylelint/stylelint#5600 (comment) for details.

@SimenB SimenB linked a pull request Oct 19, 2021 that will close this issue
@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants