我正在使用 karma 和 phantom 运行我的测试,我正在使用 mocha 和 sinon,有时测试通过了,有时我没有任何理由得到这个错误:
✖ "before each" hook: workFn
✔ should call get user api
✖ "after each" hook for "should call get user api"
Finished in 1.04 secs / 0.2 secs
SUMMARY:
✔ 42 tests completed
✖ 3 tests failed
FAILED TESTS:
UserService
✖ "before each" hook: workFn
PhantomJS 1.9.8 (Mac OS X 0.0.0)
TypeError: 'null' is not an object (evaluating 'document.querySelector('.arrow' + index).classList') (public/client/build/main.js:3195)
✖ "after each" hook for "should call get user api"
PhantomJS 1.9.8 (Mac OS X 0.0.0)
PhantomJS 1.9.8 (Mac OS X 0.0.0)
TypeError: 'null' is not an object (evaluating 'currentSpec.$injector')
at public/vendor/angular-mocks/angular-mocks.js:2229
什么会导致这个问题?