Moving Jest setup and consolidating

This commit is contained in:
Jeff Avallone 2018-02-15 17:27:15 -05:00
parent 2904519ff5
commit fcba4b75ec
4 changed files with 18 additions and 15 deletions

View File

@ -29,7 +29,7 @@
], ],
"jest": { "jest": {
"clearMocks": true, "clearMocks": true,
"setupTestFrameworkScriptFile": "<rootDir>/src/setup-jest.js", "setupTestFrameworkScriptFile": "<rootDir>/src/setup/jest.js",
"snapshotSerializers": [ "snapshotSerializers": [
"enzyme-to-json/serializer" "enzyme-to-json/serializer"
], ],

View File

@ -3,18 +3,9 @@ import { shallow } from 'enzyme';
import { Header } from 'components/Header'; import { Header } from 'components/Header';
const env = { ...process.env };
describe('Header', () => { describe('Header', () => {
afterEach(() => {
process.env = env;
});
beforeEach(() => { beforeEach(() => {
process.env = { process.env.BANNER = 'testing';
...process.env,
BANNER: 'testing'
};
}); });
test('rendering', () => { test('rendering', () => {

View File

@ -1,4 +0,0 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });

16
src/setup/jest.js Normal file
View File

@ -0,0 +1,16 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
Enzyme.configure({ adapter: new Adapter() });
const env = { ...process.env };
beforeEach(() => {
process.env = {
...process.env
};
});
afterEach(() => {
process.env = env;
});