2017-12-12 20 views
0

js 라이브러리에 대해 ES6 다시 작성을 수행하고 있습니다.ES6 : 브라우저에서 테스트가 통과되고 phantomJS가 실패합니다. "변수를 찾을 수 없습니다 : Reflect"

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