Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chai-as-promised@7 with Karma: reserved word 'let' #207

Closed
haraldrudell opened this issue Jun 14, 2017 · 7 comments
Closed

chai-as-promised@7 with Karma: reserved word 'let' #207

haraldrudell opened this issue Jun 14, 2017 · 7 comments

Comments

@haraldrudell
Copy link

haraldrudell commented Jun 14, 2017

I am not sure if there is a transpile required or a refrain from fancy new constructs.

Here is the error message:
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
SyntaxError: Use of reserved word 'let' in strict mode
at node_modules/chai-as-promised/lib/chai-as-promised.js:3

affected version: chai-as-promised@7.0.0

Get-around:
npm install chai@3 chai-as-promised@5
-> 3.5.0 + 5.3.0

@domenic
Copy link
Collaborator

domenic commented Jun 14, 2017

@domenic domenic closed this as completed Jun 14, 2017
@haraldrudell
Copy link
Author

So chai cannot be upgraded until Karma uses the not-yet-released Phantom 2.5?
ariya/phantomjs#14458

@domenic
Copy link
Collaborator

domenic commented Jun 14, 2017

Did you read the section I linked?

If your browser doesn't support modern JavaScript syntax, you'll need to transpile it down using a tool like Babel.

@haraldrudell
Copy link
Author

haraldrudell commented Jun 14, 2017

So, the solution is to add to the karma config object, a rule inside the webpack field module.rules making the babel-loader process with the test:
test: require.resolve('chai-as-promised'),

and a preprocessors field entry for the same thing:
preprocessors: {
[require.resolve('chai-as-promised')]: ['webpack'],

@baywet
Copy link

baywet commented Jul 22, 2017

In my case I don't have control over the webpack config or most of the pipeline. I ended up reverting to 6.0.0 until phantomjs fully supports es6/2015
ariya/phantomjs#14506

@aldencolerain
Copy link

If you want more detail on how to do this with Karma Webpack and PhantomJS 5 checkout my comment on the Vue.js issue: vuejs-templates/webpack#646 (comment)
Thanks @haraldrudell for the solution.

@mancioshell
Copy link

@haraldrudell i have added your advised configuration in my karma.conf.js, but it still not work, with the same error
PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
SyntaxError: Use of reserved word 'let' in strict mode

Could you post your solutions please?

Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants