4

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 がどこかの構文でより厳密になっていることに関係しているようです。しかし、この不正なコンマがどこにあるかについてのエラー メッセージには示されていません。

このコンマを見つける方法や、このエラーを何らかの方法で解決する方法について、ヒントを教えてもらえますか? 前もって感謝します。

4

1 に答える 1

6

オブジェクトに重複するプロパティ名がある場合、PhantomJS は構文エラーをスローします。

var object = { foo: 1, foo: 2 };

ほとんどのブラウザーは、これを構文エラーと見なさず、最後のプロパティ定義を使用します。

于 2016-03-27T06:32:51.937 に答える