3

現在Internet Explorer 11で実行する必要があるAureliaアプリケーションを開発中です。IE11でKarma/Tapeテストをカルマ - ランチャー。Internet ExplorerでKarmaを実行中にaurelia-testingでWaitForElementを使用

カルマが正しく起動すると、waitForDocumentElementを使用したテストが発生するまで、いくつかのテストが実行されています。 waitForDocumentElementは約束を使用しているので、私はカルマにPromiseポリフィルをロードするだけで、Chromeを使用するときと同じようにすべてが機能し始めます。しかし、明らかにそうではありませんでした。

だから、最後に質問です。私のテストをカルマで実行し、IE11をkarma-ie-launcherでターゲットにし、waitForDocumentElementをテストに使用する方法がありますか?それは約束を使用して以来、ここでは犯人と思われる。

必要に応じて、私のプロジェクトとは別にサンプルレポを構築することがあります。

ありがとうございます!

編集: 「スタック領域外」エラーのスタックトレースは次のとおりです。レコードの場合、rawValueはバインド可能なプロパティで、私はwaitForDocumentelementの中にアサーションしようとしていますので、バインディングにはすべて時間があります。

WARN: 'Unhandled rejection TypeError: Unable to get property 'rawValue' of undefined or null reference 
    at Anonymous function (http://localhost:9876/base/dist/_test/components/aurelia-numeric-input/aurelia-numeric-input.spec.js?ea0d4f3a76b6b818e30e08a7cbbc07dc5c11e02a:31:17) 
    at r (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:31:9351) 
    at i.prototype._settlePromiseFromHandler (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:14559) 
    at i.prototype._settlePromise (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:15364) 
    at i.prototype._settlePromise0 (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:16065) 
    at i.prototype._settlePromises (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:17395) 
    at r.prototype._drainQueue (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:3054) 
    at r.prototype._drainQueues (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:3112) 
    at drainQueues (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:1236) 
    at Anonymous function (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:31140)' 
WARN: 'Unhandled rejection TypeError: Unable to get property 'rawValue' of undefined or null reference 
    at Anonymous function (http://localhost:9876/base/dist/_test/components/aurelia-numeric-input/aurelia-numeric-input.spec.js?ea0d4f3a76b6b818e30e08a7cbbc07dc5c11e02a:36:17) 
    at r (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:31:9351) 
    at i.prototype._settlePromiseFromHandler (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:14559) 
    at i.prototype._settlePromise (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:15364) 
    at i.prototype._settlePromise0 (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:16065) 
    at i.prototype._settlePromises (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:17395) 
    at r.prototype._drainQueue (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:3054) 
    at r.prototype._drainQueues (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:3112) 
    at drainQueues (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:29:1236) 
    at Anonymous function (http://localhost:9876/base/node_modules/bluebird/js/browser/bluebird.min.js?3d186ac6d244691754303d3153839bf42b57f7d1:30:31140)' 
WARN: 'Unhandled rejection Error: Out of stack space 
    at _compileElement (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2691:7) 
    at _compileNode (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2547:11) 
    at compile (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2516:7) 
    at _compileElement (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2721:9) 
    at _compileNode (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2547:11) 
    at compile (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2516:7) 
    at _compileElement (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2721:9) 
    at _compileNode (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2547:11) 
    at compile (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2516:7) 
    at _compileElement (http://localhost:9876/base/node_modules/aurelia-templating/dist/amd/aurelia-templating.js?1766dc2dd0fa5489caa6a2c286fad9ab686c2f09:2721:9)' 

答えて

1

カルマは、あなたのkarma.conf.jsのパターンに一致するファイルを一覧表示します__karma__という名前のウィンドウのプロパティを作成します。通常、テストエントリポイントモジュールには、このファイル名のリストを気絶させ、拡張子を取り除くなどのコードがありますので、あなたのローダーのrequirejsに合ったモジュール名のリストになります;

この配列requirejs configのプロパティに割り当てられ、requirejs設定のcallbackプロパティに割り当てられた関数を呼び出す前に、requirejsがそれらのすべてをロードするようにします。

私は手動でブルーバードを最初の依存関係として追加しています。コールバックでは、いくつかの機能の検出を行い、プロミスがブラウザでサポートされていない場合は、window.Promiseにそれを割り当てます。

ここでは、設定にきれいにマップする必要がある例を示します。関連する行はコメントで示されます。

const testModules = Object.keys(window.__karma__.files) 
    .filter(filename => /\.spec\.js$/.test(filename)) 
    .map(filename => filename.replace(/^\/base\/dist\/|\.js$/g, '')); 

testModules.unshift('bluebird'); // make bluebird the first dependency in the array... this means it will be the first argument to the callback function (see below) 

let karmaStarted = false; 

require.config({ 
    baseUrl: '/base/global/output', 
    paths: { 
     'bluebird': '../some/path/to/bluebird.min' // ensure the loader can find bluebird 
    }, 
    deps: testModules, // bluebird is the first item in this array of modules 
    callback: (bluebird: any) => { // bluebird is the first arg... there are many other args but we don't care about the rest 
     if (karmaStarted) { 
      return; 
     } 

     // polyfill Promise on an as-needed basis. 
     if (!('Promise' in window && 'resolve' in window.Promise && 'reject' in window.Promise && 'all' in window.Promise && 'race' in window.Promise)) { 
      window.Promise = bluebird.Promise; 
     } 

     karmaStarted = true; 
     window.__karma__.start(); 
    } 
}); 
+0

ありがとうJD私は昼食後にそれを見ています! –

+0

これはちょっと助けになりましたが、 'aurelia-templating'の' Unhandled rejection Error:スタック領域外 'エラーがありました。また、waitForDocumentElementを使ったテストはまだ失敗していますが、私はもう約束が拒否されたというエラーはありません。 waitForDocumentElementを使用して、カスタム要素のバインド可能なプロパティの変更をテストしました。 –

+0

フェッチ・ポリフィルも必要ですか?同じテクニック –

関連する問題