我正在尝试配置实习(https://theintern.github.io)以进行单元测试。
这是我的配置
define([ 'intern' ], function (intern) {
// Return configuration for intern tests
var config = {
basePath: '../',
loaderOptions: {
packages: [
{ name: 'app', location: 'app' },
{ name: 'jquery', location: 'bower_components/jquery/dist/jquery' },
{ name: 'underscore', location: 'bower_components/underscore/underscore' },
{ name: 'backbone', location: 'bower_components/backbone/backbone' }
]
},
suites: [
'tests/mymodule'
],
excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)\//,
loaders: {
'host-node': 'requirejs',
'host-browser': 'bower_components/requirejs/require.js',
},
reporters: [
{id:'Console'}
]
};
return config;
});
我收到以下错误
> intern-runner config=tests/intern
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
Transformation error; return original code
TypeError: SourceNode is not a constructor
at toSourceNodeWhenNeeded (C:\repo\my-app\node_modules\escodegen\escodegen.js:535:20)
at generateIdentifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:866:16)
at CodeGenerator.Identifier (C:\repo\my-app\node_modules\escodegen\escodegen.js:2244:20)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.MemberExpression (C:\repo\\node_modules\escodegen\escodegen.js:1910:28)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
at CodeGenerator.UpdateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2009:26)
at CodeGenerator.generateExpression (C:\repo\my-app\node_modules\escodegen\escodegen.js:2427:28)
ReferenceError: __cov_YGSj0arNmIBnXUo5NAKQbw is not defined
at Object.<anonymous> <node_modules\digdug\NullTunnel.js:9:1>
at Module._compile <module.js:570:32>
at Object.Module._extensions.(anonymous function) [as .js] <node_modules\istanbul\lib\hook.js:107:24>
at Module.load <module.js:487:32>
at tryModuleLoad <module.js:446:12>
at Function.Module._load <module.js:438:3>
at Module.require <module.js:497:17>
at require <internal\module.js:20:19>
at Object.load <node_modules\intern\browser_modules\dojo\node.ts:56:11>
at Object.<anonymous> <node_modules\requirejs\bin\r.js:1347:28>
npm ERR! Test failed. See above for more details.
如何仅为单元测试配置内容?
答案 0 :(得分:0)
从错误看,node_modules
中的模块正在为代码覆盖进行检测(关于“__cov_YGSj0arNmIBnXUo5NAKQbw未定义”的位与覆盖相关)。
由于您在Windows上运行,请尝试从\/
末尾删除excludeInstrumentation
:
excludeInstrumentation: /^(?:tests|node_modules|bower_components|test)/,