在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在某些地方的语法更加严格有关。但是错误消息中没有任何迹象表明该流氓逗号位于何处。
有人可以给我一些有关如何找到此逗号或以某种方式解决此错误的提示吗?提前致谢。
当对象具有重复的属性名称时,PhantomJS会引发语法错误,例如:
var object = { foo: 1, foo: 2 };
大多数浏览器不会将此视为语法错误,而仅使用最后一个属性定义。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句