insomnia/packages/insomnia-app/app/__jest__/setup.js

31 lines
646 B
JavaScript
Raw Normal View History

import 'whatwg-fetch';
2018-06-25 17:42:50 +00:00
const localStorageMock = (function() {
let store = {};
return {
2018-06-25 17:42:50 +00:00
getItem(key) {
return store[key];
},
2018-06-25 17:42:50 +00:00
setItem(key, value) {
store[key] = value.toString();
},
2018-06-25 17:42:50 +00:00
clear() {
store = {};
},
};
})();
global.__DEV__ = false;
global.localStorage = localStorageMock;
global.requestAnimationFrame = cb => process.nextTick(cb);
global.require = require;
// Don't console log real logs that start with a tag (eg. [db] ...). It's annoying
const log = console.log;
global.console.log = (...args) => {
if (!(typeof args[0] === 'string' && args[0][0] === '[')) {
log(...args);
}
};