由于PhantomJS语法错误,Ember.js测试失败

Ern*_*sto 4 syntax-error phantomjs ember.js ember-testing

我在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: |
    ...
Run Code Online (Sandbox Code Playgroud)

注意上面的第一个错误,说明global failure然后报告意外的逗号标记.之后,所有剩余的测试都会失败,原因是它们无法导入存在的文件,或者因为testResolver未设置该文件或其他原因.

事情就是一切都在浏览器中正确运行.看起来这与PhantomJS在某处某种语法更加严格有关.但是错误消息中没有关于此流氓逗号位于何处的指示.

有人可以给我一些关于如何找到这个逗号或以某种方式解决这个错误的提示吗?提前致谢.

gal*_*ans 6

当对象具有重复的属性名称时,PhantomJS会抛出语法错误,例如:

var object = { foo: 1, foo: 2 };
Run Code Online (Sandbox Code Playgroud)

大多数浏览器不将此视为语法错误,只使用最后一个属性定义.