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?]: TypeError: (0 , _flags.default) is not a function - probably pnp (corejs and jest) related #5347

Open
1 task
smooth-man opened this issue Mar 27, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@smooth-man
Copy link

smooth-man commented Mar 27, 2023

Self-service

  • I'd be willing to implement a fix

Describe the bug

I started experiencing this TypeError: (0 , _flags.default) is not a function error after I did an update to one of our react projects, and it only happens when I try to run tests with jest. I have created two repos where the bug can be reproduced. After reading some info I think this might be related to these issues (but I'm not 100% sure)

#3708
#4045

To reproduce

The first repo where this can be reproduced

https://github.com/smooth-organization/jest-error-4

Steps that are needed in order to get the error:

  1. Clone the repo (no need to "yarn install" because of zero installs)
  2. Run both tests "yarn run test-simple" and "yarn run test-react" - they are setup in such a way that both files contain two tests - one should work, one should fail. When tests are run for the first time, you should get a lot of "Internal error in the corejs3 provider: unknown polyfill" warnings, but for the time being this is fine.
  3. Clear the resolutions field (which was added in order to use the specific versions of several packages) in the package.json file and "yarn install". After that there should be several updates in the cache folder:
    image
  4. Run both tests again. The simple one should remain unchanged, but the react one should throw the error:
    image

The second repo where the error is present

https://github.com/smooth-organization/jest-error
You need to run yarn run test-react

TypeError: (0 , _flags.default) is not a function

  4 | describe("react test", () => {
  5 |       it("should work", () => {
> 6 |               const { getByText } = render(<App />)
    |                                           ^
  7 |               expect(getByText('this is my app')).toBeTruthy()
  8 |       });
  9 | });

  at Object.<anonymous>.module.exports (.yarn/cache/core-js-pure-npm-3.28.0-172396ba34-8bef96a435.zip/node_modules/core-js-pure/es/instance/flags.js:7:84)
  at getNearestMountedFiber (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:4463:12)
  at getNearestMountedFiber (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:4549:26)
  at findCurrentFiberUsingSlowPath (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:4729:23)
  at findCurrentHostFiberWithNoPortals (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:28968:19)
  at ReactDOMRoot.findHostInstanceWithNoPortals [as render] (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:29304:26)
  at Object.render (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:122:12)
  at render (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:163:12)
  at callback (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/act-compat.js:64:24)
  at callback (.yarn/cache/react-npm-18.2.0-1eae08fee2-88e38092da.zip/node_modules/react/cjs/react.development.js:2512:16)
  at actImplementation (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/act-compat.js:63:25) 
  at renderRoot (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:159:25)
  at renderRoot (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:246:10)
  at Object.<anonymous> (src/react-test.spec.js:6:31)

  at Object.<anonymous>.module.exports (.yarn/cache/core-js-pure-npm-3.28.0-172396ba34-8bef96a435.zip/node_modules/core-js-pure/es/instance/flags.js:7:84)
  at markUpdateLaneFromFiberToRoot (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:13395:32)
  at markUpdateLaneFromFiberToRoot (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:13376:10)
  at enqueueConcurrentClassUpdate (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:13525:12)
  at enqueueUpdate (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:28855:14)
  at updateContainer (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:29337:7)
  at fn (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:26189:14)
  at ReactDOMRoot.flushSync [as unmount] (.yarn/__virtual__/react-dom-virtual-97896247fb/0/cache/react-dom-npm-18.2.0-dd675bca1c-7d323310be.zip/node_modules/react-dom/cjs/react-dom.development.js:29336:5)
  at Object.unmount (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:126:12)
  at unmount (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:262:12)
  at callback (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/act-compat.js:64:24)
  at callback (.yarn/cache/react-npm-18.2.0-1eae08fee2-88e38092da.zip/node_modules/react/cjs/react.development.js:2512:16)
  at actImplementation (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/act-compat.js:63:25) 
  at .yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:261:27
      at Array.forEach (<anonymous>)
  at forEach (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/pure.js:257:22)
  at Object.<anonymous> (.yarn/__virtual__/@testing-library-react-virtual-e9e4b497e1/0/cache/@testing-library-react-npm-13.4.0-eaa652c0f5-51ec548c1f.zip/node_modules/@testing-library/react/dist/index.js:35:24)

The issue is present on both Windows and WSL.

Environment

System:
  OS: Windows 10 10.0.22621
  CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
  Node: 18.14.0 - ...\AppData\Local\Temp\xfs-03ecf1c2\node.CMD
  Yarn: 3.1.0 - ...\AppData\Local\Temp\xfs-03ecf1c2\yarn.CMD
  npm: 9.3.1 - ...\nodejs\npm.CMD

OR

System:
  OS: Linux 5.10 Ubuntu 20.04.4 LTS (Focal Fossa)
  CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
  Node: 18.1.0 - /tmp/xfs-f3006aa2/node
  Yarn: 3.1.0 - /tmp/xfs-f3006aa2/yarn
  npm: 8.8.0 - ~/.nvm/versions/node/v18.1.0/bin/npm

Additional context

I also reported the bug to the core-js author zloirock/core-js#1183 but it seems like it's not related to that package.
I tried updating to yarn 4 (rc), corejs 3.29.1 or jest 29 but the error persists.

@smooth-man smooth-man added the bug Something isn't working label Mar 27, 2023
@onukwilip
Copy link

From what i see here, i presume you are trying to test a React Js Project, but it's throwing an error. I also noticed you are using jest as your testing library, but are you also using the react-testing-library library?

@smooth-man
Copy link
Author

smooth-man commented Apr 18, 2023

Yes, it's all in the package.json file in the mentioned repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants