Node v13 / Jest / ES6 — native support for modules without babel or esm

前端 未结 4 1419
心在旅途
心在旅途 2020-12-11 00:47

Is it possible to test ES6 Modules with Jest without esm or babel? Since node v13 supports es6 natively have tried:

//         


        
4条回答
  •  旧巷少年郎
    2020-12-11 01:40

    In addition to @Radovan Kuka's answer, here's how to run Jest with ES modules, using npx:

    "test:monitoring": "npx --node-arg=--experimental-vm-modules jest -f monitoring.test.js --detectOpenHandles",
    

    The benefit is that one doesn't need to provide the absolute node_modules path.

提交回复
热议问题