---
title: "Comment by Elle K on \"How to set up jest for es module\" | Hashnode"
description: "Great article! Note: I needed to assign &quot;jest&quot; to the &quot;test&quot; script in my package.json file in order for the npm run test script to work. &q"
url: "https://hashnode.com/posts/how-to-set-up-jest-for-es-module/61210c18a5d08237f40e09d6/comment/63445f466d64be07a724af21"
---

[Discussion](https://hashnode.com/posts/how-to-set-up-jest-for-es-module/61210c18a5d08237f40e09d6)

Comment [How to set up jest for es module](https://hashnode.com/posts/how-to-set-up-jest-for-es-module/61210c18a5d08237f40e09d6)

[Elle K](https://hashnode.com/@DevElleUp)

[Oct 10, 2022](https://hashnode.com/posts/how-to-set-up-jest-for-es-module/61210c18a5d08237f40e09d6/comment/63445f466d64be07a724af21)

Great article! Note: I needed to assign "jest" to the "test" script in my package.json file in order for the `npm run test` script to work.

```
"scripts": {
    "test": "jest"
  },
```

Out of the box, that comes as

```
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
```

Also, I can confirm that in Oct '22, I did not need to create the .bablerc config file. I found this article because I was trying to use `spyOn` and getting the error: `SyntaxError: The requested module jest/globals does not provide an export named spyOn`. Installing the plugin to transform ES6 (modules) to CommonJS (`@babel/plugin-transform-modules-commonjs`) fixed this issue, exposing the spyOn function properly for use in my test files.

[Marcin Wosinek](https://hashnode.com/@marcin-wosinek)

[Oct 11, 2022](https://hashnode.com/posts/how-to-set-up-jest-for-es-module/61210c18a5d08237f40e09d6/comment/63445f466d64be07a724af21#reply-63456ade07f4e412d7b028af)

Thank you so much for sharing all this information!
