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

Running import { test, fc } from '@fast-check/jest'; results in error reading properties of undefined in jest #4986

Open
CMCDragonkai opened this issue May 15, 2024 · 6 comments

Comments

@CMCDragonkai
Copy link

🐛 Bug Report

I'm trying to use the latest ESM version of @fast-check/jest. I got everything else working.

As soon as I try to import import { test, fc } from '@fast-check/jest'; there seems to be some problem with some undefined property.

  ● Test suite failed to run

    TypeError: Cannot read properties of undefined (reading 'only')

      at internalTestPropConcurrent (node_modules/@fast-check/jest/lib/esm/internals/TestPropBuilder.js:25:43)
      at internalTestProp (node_modules/@fast-check/jest/lib/esm/internals/TestPropBuilder.js:32:18)
      at node_modules/@fast-check/jest/lib/esm/jest-fast-check.js:7:25

Seems something isn't quite working..

To Reproduce

Steps to reproduce:

  1. Go here Migrating to ESM MatrixAI/js-table#3
  2. Try to run npm test

Expected behavior

Clear and concise description of what you expected to happen.

That it just imports properly.

If you have one, please provide a minimal repository reproducing the issue on GitHub.

Your environment

Packages / Softwares Version(s)
fast-check ^3.10.0
node v20.5.1
TypeScript* ^5.1.6

*Only for TypeScript's users

@CMCDragonkai
Copy link
Author

CMCDragonkai commented May 15, 2024

This line in node_modules/@fast-check/jest/lib/esm/jest-fast-check.js.

import { it as itJest, test as testJest, jest } from '@jest/globals';

Doesn't work as testJest is undefined. It appears it does not exist. However jest does exist.

@CMCDragonkai
Copy link
Author

This is the latest version of jest. So I don't think the @jest/globals exports the test property anymore.

@dubzzz
Copy link
Owner

dubzzz commented May 15, 2024

Strange... I have some tests checking ES Module mode 🤔 (tests here)
I'll check if they correctly setup Jest for such usage...

In he meantime, a shorter and minimal reproduction case could help me into investigating. Current test case is a bit too huge to start an investigation without loosing time trying to understand how the project works, is setup...

@dubzzz
Copy link
Owner

dubzzz commented May 15, 2024

I'll probably check and extend my tests to use the test and not the testProp thing so that it gets closer to my latest recommendations.

@CMCDragonkai
Copy link
Author

Well I sort of debugged it by editing these 3 files:

      at internalTestPropConcurrent (node_modules/@fast-check/jest/lib/esm/internals/TestPropBuilder.js:25:43)
      at internalTestProp (node_modules/@fast-check/jest/lib/esm/internals/TestPropBuilder.js:32:18)
      at node_modules/@fast-check/jest/lib/esm/jest-fast-check.js:7:25

Monkey patching it with console.log indicated this #4986 (comment) being the problem.

I don't think @jest/globals exports test anymore.

@CMCDragonkai
Copy link
Author

If you have nix-shell, you can just enter nix-shell first.

If not, an npm install then npm test should suffice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants