我有一个用coffeescript编写的基本规范:
# test/foobar.spec.coffee
describe "falsy test", ->
it "should fail", ->
expect(true).toBe false当我从项目目录运行jasmine-node --coffee test/foobar.spec.coffee时,我得到以下错误:
Exception loading: /Users/myuser/programming/project/test/foobar.spec.coffee
{ [Error: Cannot find module '/Users/myuser/programming/project/test/foobar.spec'] code: 'MODULE_NOT_FOUND' }我正在使用:
node --version
v0.10.8
jasmine-node --version
1.13.0有人知道为什么会这样吗?
发布于 2014-07-11 21:29:45
我在其他包(require,supertest)中也遇到了类似的问题。似乎如果你全局安装它们(npm install -g),你会得到这个错误。使用本地安装(没有-g选项),一切似乎都很正常。
发布于 2018-12-30 10:09:58
我以一种奇怪的方式遇到了这个错误。
下面的代码可以工作,
function someFunc(){
//do something
}
describe(testCases.testCaseRegister.name, async function(){
someFunc();
//ensure ample time for database to be setup properly
await new Promise(done => setTimeout(done, 5000));
}但当我更改为此时,错误会出现,偶尔会出现“语法错误:等待仅在异步函数中有效”。
function someFunc(){
//do something
await new Promise(done => setTimeout(done, 5000));
}
describe(testCases.testCaseRegister.name, async function(){
someFunc();
}切换回我的原始代码,解决了所有这些错误。
https://stackoverflow.com/questions/21439920
复制相似问题