DEV Community

Olen Daelhousen
Olen Daelhousen

Posted on

1 1

Setup to Test ES Modules with Jest 27.4.5 and Node 14.16.0 on Windows

For a side project I'm working on, I decided to try out ECMAScript (ES) Modules, because the latest versions of Node now support them and the latest browsers do too. Sadly, I quickly discovered that my favorite testing framework, Jest, requires a bit of configuration to work with them and the support is experimental. As such, this post is mostly a reminder to my future self in case I need to do this again, but possibly others may find it useful.

I made the following changes and/or additions to package.json and jest.config.mjs:

package.json

  "scripts": {
    "test": "node --experimental-vm-modules node_modules/jest/bin/jest.js"
  },
Enter fullscreen mode Exit fullscreen mode

jest.config.mjs

  testEnvironment: "jest-environment-node",
  transform: {},
Enter fullscreen mode Exit fullscreen mode

Those were the only changes I needed to make to successfully test ES Modules with Jest 27, Node 14, and Windows 10.

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️