Javascript Jest测试返回语法错误:NodeModule中出现意外字符串
我尝试运行jest测试最初用于Mocha的文件时出错:Javascript Jest测试返回语法错误:NodeModule中出现意外字符串,javascript,jestjs,Javascript,Jestjs,我尝试运行jest测试最初用于Mocha的文件时出错: ● Test suite failed to run /Users/[user]/Repos/[repo]/node_modules/hubot-auth/index.coffee:1 ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){fs = require '
● Test suite failed to run
/Users/[user]/Repos/[repo]/node_modules/hubot-auth/index.coffee:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){fs = require 'fs'
SyntaxError: Unexpected string
11 | const init = require('../../scripts/admin');
12 | const auth_middleware = require('../../scripts/auth_middleware');
> 13 | const hubot_auth = require('hubot-auth');
| ^
14 | const nock = require('nock');
15 |
16 | const {Robot,TextMessage} = require('hubot');
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1350:14)
at Object.require (test/script/admin_test.js:13:20)
jest.config.js
const coffee = require('coffeescript');
const babelJest = require('babel-jest');
module.exports = {
process: (src, path, ...rest) => {
if (coffee.helpers.isCoffee(path)) {
// Compile the CoffeeScript files to JSX
compiled_to_js = coffee.compile(src, {bare: true});
return babelJest.process(compiled_to_js, path, ...rest);
}
return src;
}
};
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/en/configuration.html
*/
module.exports = {
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// The glob patterns Jest uses to detect test files
testMatch: [
"**/test/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
"/node_modules/"
],
transformIgnorePatterns: [
"/node_modules/",
"\\.pnp\\.[^\\/]+$"
],
};
这个设置仍然会产生同样的错误,这让我觉得coffeescript仍然没有被编译,我不知道为什么,感觉好像我已经到了死胡同。
有人克服过类似的问题吗
/*
* For a detailed explanation regarding each configuration property, visit:
* https://jestjs.io/docs/en/configuration.html
*/
module.exports = {
// Indicates which provider should be used to instrument code for coverage
coverageProvider: "v8",
// The glob patterns Jest uses to detect test files
testMatch: [
"**/test/**/*.[jt]s?(x)",
"**/?(*.)+(spec|test).[tj]s?(x)"
],
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
testPathIgnorePatterns: [
"/node_modules/"
],
transformIgnorePatterns: [
"/node_modules/",
"\\.pnp\\.[^\\/]+$"
],
};