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

查看:107
本文介绍了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.

提前感谢您的帮助。

推荐答案

由于节点不支持模块,您必须使用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天全站免登陆