Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { configure } from 'enzyme';
import { JSDOM } from 'jsdom';
// enzyme requires special adapters now that are in different modules
// as opposed to different imports, so we need to configure it based on
// which React version we're testing
if (process.env.REACT_VERSION === '^15.4.0') {
const Adapter = require('enzyme-adapter-react-15.4');
configure({ adapter: new Adapter() });
} else if (process.env.REACT_VERSION === '<15.4.0 >15.0.0') {
const Adapter = require('enzyme-adapter-react-15');
configure({ adapter: new Adapter() });
} else {
const Adapter = require('enzyme-adapter-react-16');
configure({ adapter: new Adapter() });
}
module.exports = function(root) {
root = root ? root : global;
root.expect = root.chai.expect;
const dom = new JSDOM('');
root.window = dom.window;
root.document = dom.window.document;
beforeEach(() => {
// Using these globally-available Sinon features is preferrable, as they're
// This is a configuration file for Jest
import './sprockets-shims.js';
import '../legacy.js';
// Enzyme support
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15.4';
Enzyme.configure({ adapter: new Adapter() });
// These are for MountTimer and measurePageLoad.
// See https://gist.github.com/ShirtlessKirk/eb41720a797411defae6
import './performance-timing-api.js';
import {performance} from 'perf_hooks';
global.performance = performance;
// https://github.com/jefflau/jest-fetch-mock
global.fetch = require('jest-fetch-mock'); // eslint-disable-line no-undef
// Make console.warn and error fail tests
console.error = jest.fn(error => { throw new Error(error); }); //eslint-disable-line no-console
console.warn = jest.fn(warn => { throw new Error(warn); }); //eslint-disable-line no-console
// Make test fail if code is reporting errors to Rollbar
window.Rollbar = {
import {defaultState as defaultGtfsStopsState} from '../../../lib/gtfs/reducers/stops'
import {defaultState as defaultGtfsTimetablesState} from '../../../lib/gtfs/reducers/timetables'
import {defaultState as defaultGtfsValidationState} from '../../../lib/gtfs/reducers/validation'
import * as gtfsPlusReducers from '../../../lib/gtfsplus/reducers'
import {defaultState as defaultGtfsPlusState} from '../../../lib/gtfsplus/reducers/gtfsplus'
import * as managerReducers from '../../../lib/manager/reducers'
import {defaultState as defaultManagerLanguagesState} from '../../../lib/manager/reducers/languages'
import {defaultState as defaultManagerProjectsState} from '../../../lib/manager/reducers/projects'
import {defaultState as defaultManagerStatusState} from '../../../lib/manager/reducers/status'
import {defaultState as defaultManagerUiState} from '../../../lib/manager/reducers/ui'
import {defaultState as defaultManagerUserState} from '../../../lib/manager/reducers/user'
import * as manager from './manager'
import type {AppState} from '../../../lib/types/reducers'
Enzyme.configure({ adapter: new EnzymeReactAdapter() })
const defaultManagerState = {
languages: defaultManagerLanguagesState,
projects: defaultManagerProjectsState,
status: defaultManagerStatusState,
ui: defaultManagerUiState,
user: defaultManagerUserState
}
const defaultRouterLocation = {
action: '',
hash: '',
key: '',
pathname: '',
query: {},
search: ''
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15.4';
Enzyme.configure({ adapter: new Adapter() });
export default Enzyme;