Skip to content

doc(docs.mockFunctions): use SAME JS module system #15486

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

Merged

Conversation

dancer1325
Copy link
Contributor

@dancer1325 dancer1325 commented Feb 3, 2025

Summary

  • In Using a mock function, you can see that
    • in js title="forEach.test.js" , that require is used == CommonJS
    • in js title="forEach.js", that export is used == ES
  • ⚠️That's why lot of pitfalls you will get, mixin them ⚠️
  • Solution:
    • align to use CommonJS in both files defined

Test plan

  • Create both 2 files
  • Create the minimum set up to make jest work -- see gettingStarted --
  • Run it to test
    image

Copy link

linux-foundation-easycla bot commented Feb 3, 2025

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: cpojer / name: Christoph Nakazawa (48b204c)
  • ✅ login: dancer1325 / name: dancer13 (e416d58)

Copy link

netlify bot commented Feb 3, 2025

Deploy Preview for jestjs failed.

Built without sensitive environment variables

Name Link
🔨 Latest commit 48b204c
🔍 Latest deploy log https://app.netlify.com/projects/jestjs/deploys/682edbec0f9d0e0008624775

@dancer1325
Copy link
Contributor Author

maybe @SimenB ?

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks! Mind updating the other versions of the doc as well?

@cpojer
Copy link
Member

cpojer commented May 22, 2025

Let's use ESM. No need to update older version of the docs with this tbh.

@cpojer cpojer merged commit 57568be into jestjs:main May 22, 2025
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants