【发布时间】:2017-01-30 20:57:29
【问题描述】:
我正在编写一个 Jest 集成测试来测试我的服务器。这是我的测试:
import { app, port } from '../server' // the other lines are not so important
...
运行jest 时会引发错误:
__tests__/graphql.test.js
● Test suite failed to run
<project folder>/node_modules/papercut/lib/papercut.coffee:3
{FileStore, S3Store, TestStore } = require('./store')
^
SyntaxError: Unexpected token =
我在 Jest 测试中需要 server.js,此文件需要 upload.js,而此文件需要名为 papercut 的节点模块。问题是,它是用 CoffeeScript 编写的,而不是纯 JS。
一开始我有这个错误:Jest: cannot find module required inside module to be tested (relative path)。我将coffee 添加到我的package.json 的jest 配置中:
"jest": {
"moduleFileExtensions": ["js", "json", "jsx", "node", "coffee"]
},
但现在我遇到了上面描述的错误。
我该如何处理?
【问题讨论】:
-
也许可以看看question 的“第二次尝试”部分,因为它展示了如何在导入时编译咖啡
标签: javascript coffeescript jestjs