我正在尝试使用npm run test
在我的环境中运行README脚本(也可以在https://github.com/acvetkov/sinon-chrome/blob/master/examples/navigate.test.js中显示)下的测试,但是遇到一个奇怪的错误。
首先:我已将Chrome的导入行更改为使用lib(而不是示例中的..src文件夹)
myProject\extension\test\affiliates.test.js:1
(function (exports, require, module, __filename, __dirname) { import chrome from 'sinon-chrome/extensions'
^^^^^^
SyntaxError: Unexpected identifier
at new Script (vm.js:80:7)
at createScript (vm.js:274:10)
at Object.runInThisContext (vm.js:326:10)
at Module._compile (internal/modules/cjs/loader.js:664:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at myProject\extension\node_modules\mocha\lib\mocha.js:330:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (myProject\extension\node_modules\mocha\lib\mocha.js:327:14)
at Mocha.run (myProject\extension\node_modules\mocha\lib\mocha.js:804:10)
at Object.exports.singleRun (myProject\extension\node_modules\mocha\lib\cli\run-helpers.js:207:16)
at exports.runMocha (myProject\extension\node_modules\mocha\lib\cli\run-helpers.js:300:13)
at Object.exports.handler.argv [as handler] (myProject\extension\node_modules\mocha\lib\cli\run.js:296:3)
at Object.runCommand (myProject\extension\node_modules\yargs\lib\command.js:242:26)
at Object.parseArgs [as _parseArgs] (myProject\extension\node_modules\yargs\yargs.js:1104:24)
at Object.parse (myProject\extension\node_modules\yargs\yargs.js:566:25)
at Object.exports.main (myProject\extension\node_modules\mocha\lib\cli\cli.js:63:6)
at Object.<anonymous> (myProject\extension\node_modules\mocha\bin\_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! obfuscate@0.1.0 test: `mocha`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the obfuscate@0.1.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我已经安装了mocha
和sinon-chrome
,这是我在package.json
中的测试脚本:
"main": "Gruntfile.js",
"scripts": {
"test": "mocha"
},
您可以看到我的项目也使用grunt,所以我在想这是否可能是此错误的根源。
有人对此有任何线索吗?