2017-12-12 6 views
0

jsライブラリのES6書き換えを実行しています。ES6:テストがphantomJSで失敗しました。「変数が見つかりません:反映」

class VerbalExpression extends RegExp { 
    // snipped for brevity 
} 

/** 
* Alias for the constructor 
* @return {VerbalExpression} new instance of VerbalExpression 
*/ 
function instantiate() { 
    return new VerbalExpression(); 
} 

// UMD (Universal Module Definition) 
// https://github.com/umdjs/umd 
if (typeof module !== 'undefined' && module.exports) { // CommonJS 
    module.exports = instantiate; 
} else if (typeof define === 'function' && define.amd) { // AMD Module 
    define('VerEx', [],() => VerbalExpression); 
} else { // Browser 
    this.VerEx = instantiate; 
} 

私のブラウザでテストを実行すると、すべてが合格になります。

tests pass in browser

私はターミナルでテストを実行する場合しかし、私はエラーを取得します。

❯ npm test 

[email protected] test /Users/shreyasminocha/dev/open source/JSVerbalExpressions 
grunt test 

Running "qunit:files" (qunit) task 
Testing test/index.html FFFFFFFFFFFFFFFFFFFF 
>> something 
>> Message: Died on test #1 global [email protected]:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/test/tests.js:7:5: Can't find variable: Reflect 
>> Actual: null 
>> Expected: undefined 
>> [email protected]:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:11:31 
>> [email protected]:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:59:130 
>> [email protected]:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/dist/verbalexpressions.js:588:32 
>> [email protected]:///Users/shreyasminocha/dev/open%20source/JSVerbalExpressions/test/tests.js:8:26 

... 

Warning: 20 tests completed with 20 failed, 0 skipped, and 0 todo. 
20 assertions (in 91ms), passed: 0, failed: 20 Use --force to continue. 

:私はつまり、私はテストを実行する前に、バベルを実行して、コンパイル済みのES6コードのテストを実行しています。

私はこれがPhantomJSと関係があると推測しています。ターミナルでテストをパスするにはどうすればよいですか?何か不足していますか?回避策はありますか?

答えて

0

安定したPhantomJSはES6をサポートしておらず、開発中でもありませんが、可能であればPhantomJSの影響を強く受けているpuppeteerに移行します。

+0

人形を使用してpuppeteerを使用してQunitテストを実行するにはどうすればよいですか? – shreyasminocha

+0

申し訳ありませんが、私はいつもGoogleに私のアクセス権を引き継いでいます...これは役に立ちますか? https://dtaylor.uk/blog/2017/08/chrome-qunit/ – Vaviloff

関連する問題