I saw another questions with similar issue but their solutions don't work in my case. I have properly js-dom set up:
const jsdom = require('jsdom').jsdom; // could throw
const exposedProperties = ['window', 'navigator', 'document'];
global.document = jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
exposedProperties.push(property);
global[property] = document.defaultView[property];
}
});
and require this file before all other in my npm test launch
"scripts": {
"test": "mocha --require mock-local-storage ./src/test_helper.js --compilers js:babel-core/register,css:excluders_for_mocha_tests.js --recursive ./src/**/__test__/*_test.js --watch"
}
but this doesn't help me. Interesting note: first time i launch tests there are no errors but after first saving 28 errors appear...
I read info that jasmine could use test code before test-helper was required. Maybe mocha does similar?
Aucun commentaire:
Enregistrer un commentaire