Jest es6 模块:意外的模块导入 [英] Jest es6 modules: unexpected module import

查看:32
本文介绍了Jest es6 模块:意外的模块导入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试测试一个需要像这样导入 es6 模块的文件:

I'm trying to test a file which needs to import an es6 module like this:

https://repl.it/HG9t/0

我似乎缺少一些配置以使其正常工作.

It seems I'm missing some configurations to make it work properly.

如果您可以使用另一个单元测试框架轻松实现这一点,我也很感兴趣.

If you can achieve this with another unit testing framework easily, I'm interested too.

预先感谢您的帮助.

推荐答案

由于 node 不支持模块,因此您必须使用 Babel 编译文件.查看 docs 了解如何配置 Jest 和 Babel

As node does not support modules you have to compile your files using Babel. Have a look at the docs on how to configure Jest and Babel

这篇关于Jest es6 模块:意外的模块导入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆