DEV Community

Discussion on: Setup jest from scratch in a vanilla js project.

Collapse
 
yyildiz profile image
Yusuf Yildiz

Thank you for this fantastic post Manuel! Was super easy to follow along

Collapse
 
manuartero profile image
Manuel Artero Anguita 🟨

Glad you found this useful! is it there any extra area you'd like to read about ?

Collapse
 
agassiot profile image
Andrew Gassiot

Actually yes! From your β€˜import’ syntax, I assume you are using ECMAScript Modules? Could you maybe elaborate on specifically what all you do that allowed you to use jest with .mjs files?

Thread Thread
 
manuartero profile image
Manuel Artero Anguita 🟨

Sure!

  • test files are transpiled - by babel:
 transform: {
   '\\.[jt]sx?$': 'babel-jest',
 },
Enter fullscreen mode Exit fullscreen mode

who is in charge of reading cool-js and getting boring-js on return.

  • I'm using a preset (a ready to go) configuration: present-env
presets: ["@babel/preset-env"],
Enter fullscreen mode Exit fullscreen mode

In particular, you may find the babeljs.io/docs/en/babel-preset-en... useful

Thread Thread
 
agassiot profile image
Andrew Gassiot

Ah ok, I see now. And yes, going to babel’s documentation was much more helpful than all the time I’ve spent on Jest documentation.

So babel is just handling everything, then. Thrilled to get the quick and helpful response, but the answer is a total bummer. I kinda figured Jest would be almost fully converted by now