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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot redefine property: restore #10612

Closed
guilhermetelles opened this issue Oct 9, 2020 · 5 comments
Closed

TypeError: Cannot redefine property: restore #10612

guilhermetelles opened this issue Oct 9, 2020 · 5 comments

Comments

@guilhermetelles
Copy link

guilhermetelles commented Oct 9, 2020

馃悰 Bug Report

We use a monorepo, and most of the time when we try to test a file that imports another module from the monorepo, an error occurs. One of the most common is:

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

      1 | export * from "./src/shop";
    > 2 | export * from "./src/payment";
        | ^

We've even tried jest without babel, since now ES modules are partially supported (#9430). However, we had some problems, specifically #10025

In this small repo, when I removed the rewire-exports babel plugin from the config file it seemed to work (even though I didn't tried to rewire any module), but in my official repo I received the following error:

TypeError: content.match is not a function
    at separateMessageFromStack (/home/telles/workspace/yggdrasil/node_modules/.pnpm/jest-message-util@25.5.0/node_modules/jest-message-util/build/index.js:414:32)
    at formatExecError (/home/telles/workspace/yggdrasil/node_modules/.pnpm/jest-message-util@25.5.0/node_modules/jest-message-util/build/index.js:180:21)
    at onFailure (/home/telles/workspace/yggdrasil/node_modules/.pnpm/@jest/core@25.5.4/node_modules/@jest/core/build/TestScheduler.js:206:74)
    at /home/telles/workspace/yggdrasil/node_modules/.pnpm/jest-runner@25.5.4/node_modules/jest-runner/build/index.js:112:27

Link to repl or repo (highly encouraged)

https://github.com/guilhermetelles/test-error-repo

To Reproduce

cd reaction-shops-plugin-api/
npm i
jest

Expected behavior

Jest with babel should import modules correctly

envinfo

System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i7-10510U CPU @ 1.80GHz
Binaries:
Node: 13.14.0 - ~/.nvm/versions/node/v13.14.0/bin/node
npm: 6.14.4 - ~/.nvm/versions/node/v13.14.0/bin/npm
npmPackages:
jest: ^25.1.0 => 25.5.4


@luiznasciment0
Copy link

I'm having a very similar error :(

Screen Shot 2021-03-23 at 14 53 31

@eventlistener
Copy link

There's a quite similar exception when using babel-plugin-rewire, see speedskater/babel-plugin-rewire#144. The OP seems to use a different plugin though, babel-plugin-rewire-exports. Out of curiosity, I tried swapping babel-plugin-rewire for babel-plugin-rewire-exports in my repro without changing anything else and got the exception as well. It looks like both plugins have the same bug!

@github-actions
Copy link

github-actions bot commented Aug 4, 2023

This issue is stale because it has been open for 1 year with no activity. Remove stale label or comment or this will be closed in 30 days.

@github-actions github-actions bot added the Stale label Aug 4, 2023
@github-actions
Copy link

github-actions bot commented Sep 3, 2023

This issue was closed because it has been stalled for 30 days with no activity. Please open a new issue if the issue is still relevant, linking to this one.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2023
@github-actions
Copy link

github-actions bot commented Oct 4, 2023

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 Oct 4, 2023
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

4 participants