使用Mocha进行Inversify测试会导致奇怪的错误ERROR_MSGS.NULL_ARGUMENT

时间:2017-04-12 14:38:29

标签: node.js tdd mocha inversifyjs

当我尝试使用Mocha / Chai测试代码时,我收到以下错误 有没有其他人看到这个错误?


/Users/me/Sites/my_project/node_modules/inversify/lib/container/lookup.js:13
            throw new Error(ERROR_MSGS.NULL_ARGUMENT);
            ^

Error: NULL argument
    at Lookup.add (/Users/me/Sites/my_project/node_modules/inversify/lib/container/lookup.js:13:19)
    at Container.bind (/Users/me/Sites/my_project/node_modules/inversify/lib/container/container.js:121:33)
    at Object. (/Users/me/Sites/my_project/test/api-temp/dependency-injection.js:9:15)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/Users/me/Sites/my_project/test/api-temp/services/some.service.js:21:32)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object. (/Users/me/Sites/my_project/test/api-temp/services/some.service.spec.js:4:24)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at /Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:222:27
    at Array.forEach (native)
    at Mocha.loadFiles (/Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:219:14)
    at Mocha.run (/Users/me/Sites/my_project/node_modules/mocha/lib/mocha.js:487:10)
    at Object. (/Users/me/Sites/facecards-api/node_modules/mocha/bin/_mocha:459:18)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:139:18)
    at node.js:968:3

npm ERR! Darwin 16.5.0
npm ERR! argv "/Users/me/.nvm/v4.4.5/bin/node" "/Users/dan/.nvm/v4.4.5/bin/npm" "run" "test-api" "-w"
npm ERR! node v4.4.5
npm ERR! npm  v2.15.5
npm ERR! code ELIFECYCLE
npm ERR! my_project@1.0.0 test-api: `mocha -R spec './test/api-temp/**/*.spec.js' --reporter min --inline-diffs`
npm ERR! Exit status 1

当我尝试在我的测试代码中新建类时,会出现问题。

describe('SomeService', () => {

    let someService: any

    someService = new SomeService(null, null, null)
    mockFunction = sinon.createStubInstance(someService, 'function')

     describe('#function', () => {

         beforeEach(() => {
             result = someService.function(1234)
         })

         it('should call function', () => {
             expect(.callCount).to.eql(1)
         })
     })

})

0 个答案:

没有答案