我在Ember应用程序中运行测试时遇到此错误。 显然存在语法错误( Unexpected token ',' ),其发生的方式使得测试环境的负载失败,因此它会使每个测试失败。
$ ember test version: 1.13.13 Built project successfully. Stored in "/Users/ernesto/code/projects/my-app/frontend/tmp/class-tests_dist-cqvfx9XF.tmp". not ok 1 PhantomJS 2.0 - global failure --- actual: > null message: > SyntaxError: Unexpected token ',' Log: | ... not ok 2 PhantomJS 2.0 - global failure --- actual: > null message: > Error: Could not find module `frontend/config/environment` imported from `frontend/tests/helpers/resolver` Log: | ... not ok 3 PhantomJS 2.0 - global failure --- actual: > null message: > Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". Log: | ... not ok 4 PhantomJS 2.0 - Integration | Component | dropdown filter: it renders all given options and the empty option --- actual: > null message: > Promise rejected before it renders all given options and the empty option: you must set a resolver with `testResolver.set(resolver)` Log: | ...注意上面的第一个错误,即global failure ,然后报告意外的逗号令牌。 之后,所有剩余的测试都会失败,原因可能是它们无法导入存在的文件,或者因为未设置testResolver或其他原因。
事情就是一切都在浏览器中正确运行。 看起来这与PhantomJS在某处对某些语法更加严格有关。 但是错误消息中没有关于此流氓逗号位于何处的指示。
有人能给我一些关于如何找到这个逗号或以某种方式解决这个错误的提示吗? 提前致谢。
I'm getting this error when running my tests in an Ember application. Apparently there's a syntax error (Unexpected token ',') that is occurring in a way that makes the very loading of the test environment fail, therefore it consequently makes every single test fails.
$ ember test version: 1.13.13 Built project successfully. Stored in "/Users/ernesto/code/projects/my-app/frontend/tmp/class-tests_dist-cqvfx9XF.tmp". not ok 1 PhantomJS 2.0 - global failure --- actual: > null message: > SyntaxError: Unexpected token ',' Log: | ... not ok 2 PhantomJS 2.0 - global failure --- actual: > null message: > Error: Could not find module `frontend/config/environment` imported from `frontend/tests/helpers/resolver` Log: | ... not ok 3 PhantomJS 2.0 - global failure --- actual: > null message: > Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js". Log: | ... not ok 4 PhantomJS 2.0 - Integration | Component | dropdown filter: it renders all given options and the empty option --- actual: > null message: > Promise rejected before it renders all given options and the empty option: you must set a resolver with `testResolver.set(resolver)` Log: | ...Notice the first error above, that says global failure and then reports the unexpected comma token. After that, all remaining tests fail, either because they cannot import a file that exists, or because the testResolver is not set, or something else.
The thing is everything runs correctly in the browser. It appears that this has to do with PhantomJS being more strict with some syntax somewhere. But there's no indication in the error message about where this rogue comma is located.
Can someone give me some hints about how to find this comma or solve this error somehow? Thanks in advance.
最满意答案
当对象具有重复的属性名称时,PhantomJS会抛出语法错误,例如:
var object = { foo: 1, foo: 2 };大多数浏览器不会将此视为语法错误,只使用最后一个属性定义。
PhantomJS throws a syntax error when an object has duplicate property names, eg:
var object = { foo: 1, foo: 2 };Most browsers don't view this as a syntax error and just use the last property definition.
更多推荐
发布评论