我正在编写一个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:无法找到模块内部需要测试的模块(相对路径)。我将coffee添加到package.json的jest配置中,如下所示:
"jest": {
"moduleFileExtensions": ["js", "json", "jsx", "node", "coffee"]
},但是现在我有了前面描述的错误。
我该怎么处理呢?
发布于 2016-09-29 12:12:38
我最终做了两件事来解决这个问题:
"preprocessorIgnorePatterns": []添加到Jest中。如果您不明确地告诉.coffee文件您也想编译这些文件,那么Jest会忽略node_modules/中的well文件。https://stackoverflow.com/questions/39636361
复制相似问题