Applying polyfill before loading mocha
See original GitHub issueI am trying to run emulated IE9- tests for my error manager lib using the folowing custom launcher:
IE9: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE9',
flags: ['-extoff']
},
I got the following error message:
IE 11.0.0 (Windows 7.0.0) ERROR: 'This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.'
IE 11.0.0 (Windows 7.0.0) ERROR
{
"message": "'Uint8Array' nincs definiálva\nat node_modules/mocha/mocha.js:6676",
"str": "'Uint8Array' nincs definiálva\nat node_modules/mocha/mocha.js:6676"
}
So mocha requires Uint8Array to run and I need a polyfill to fix this. I have found a typedarray polyfill, which might work on IE9- browsers too: https://github.com/inexorabletash/polyfill/blob/master/typedarray.js
I just don’t know how I can apply it before running mocha. Adding it to the files
array does not work, since it is loaded after mocha. Any ideas?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:6 (1 by maintainers)
Top Results From Across the Web
Running Mocha 6 ES6 tests with Babel 7, how to set up?
Below steps are for applying Babel transformations & core-js polyfills for your tests file: All transformations are only done per current ...
Read more >Building: Polyfills loader - Modern Web
The polyfills loader makes it easy to manage loading polyfills and/or serving different versions of your application based on browser support.
Read more >Testing in ES6 with Mocha and Babel 6 - James K Nelson
Loading babel-polyfill in your tests won't load it for your consumers too. Be careful.
Read more >Shimming - webpack
To be safe and robust, polyfills/shims must run before all other code, and thus either need to load synchronously, or, all app code...
Read more >Shimming - webpack 3 documentation
Before we do anything let's take another look at our project: project ... we can add the logic to conditionally load our new...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@maksimr @inf3rno
Thanks! Was able to fix the problem with:
I’m using core-js but I think it should work with other libraries as well
Anyway, do I understand correctly that the described approach polyfills everything that is loaded instead of just mocha?
If that is indeed the expected behavior, I don’t think this is a suitable approach for a test runner.
The whole point of testing in IE9 & IE10 is usually to detect whether those browsers don’t break because you rely on features not present in such old browsers. Adding a polyfill for ES6 features in your test environment kinda prevents you from detecting this problem.
I’d rather just use Mocha v4 instead.