gpt4 book ai didi

javascript - 每次 Hook 错误前的 Angular 业力幻影

转载 作者:数据小太阳 更新时间:2023-10-29 04:18:04 25 4
gpt4 key购买 nike

我正在使用 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

什么会导致这个问题?

最佳答案

根据我的经验,使用 Karma 和/或 PhantomJS 的 DOM 调用可能会出现问题。 PhantomJS 中的 DOM 并不完全像标准浏览器那样运行,因此,它在 GUI 操作上往往会出错。

我的建议(虽然它可能不是最好的)是监视或模拟你在 document 之外使用的文档方法,因为无论如何它们所做的都不在你的手中。

关于javascript - 每次 Hook 错误前的 Angular 业力幻影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34307451/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com