NWJS_Hour_Tracking/tests/unit/setup.js
The Jared Wilcurt 0c4f455122 Testing
2019-09-16 00:49:40 -04:00

58 lines
1.2 KiB
JavaScript

import Vue from 'vue';
const { getComputedStyle } = window;
Vue.config.productionTip = false;
// Prevents console log message to install Vue DevTools
Vue.config.devtools = false;
// Monkeypatch JSDOM missing transition styles + vue-test-utils not properly stubbing transitions
// in globally included libs (VeeValidate in our case)
// https://github.com/vuejs/vue-test-utils/issues/839#issuecomment-410474714
window.getComputedStyle = function getComputedStyleStub (el) {
return {
...getComputedStyle(el),
transitionDelay: '',
transitionDuration: '',
animationDelay: '',
animationDuration: ''
};
};
global.beforeEach(() => {
window.process = {
env: {
NODE_ENV: 'development'
},
versions: {
chromium: '76.0.3809.132',
nw: '0.40.2',
'nw-flavor': 'sdk',
node: '12.9.1'
}
};
window.nw = {
Shell: {
openExternal: jest.fn()
},
Window: {
get: function () {
return {
showDevTools: jest.fn(),
closeDevTools: jest.fn()
};
}
}
};
});
global.afterEach(() => {
window.nw.Window.get().showDevTools.mockClear();
});
// Jest's setTimeout defaults to 5 seconds.
// Bump the timeout to 60 seconds.
jest.setTimeout(60 * 1000);