Skip to content

Commit

Permalink
feat(tests): adds react testing library configurations
Browse files Browse the repository at this point in the history
  • Loading branch information
riyalohia committed Jul 23, 2020
1 parent e396caa commit ed8a2a4
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const config = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx'],
modulePaths: ['core'],
collectCoverageFrom: ['core/**/*.{ts,tsx}', '!**/dist/**/*'],
setupFilesAfterEnv: ['./scripts/setupTest.js'],
setupFilesAfterEnv: ['./scripts/setupTest.ts'],
transformIgnorePatterns: [`/node_modules/(?!${esModules})`],
snapshotSerializers: ['enzyme-to-json/serializer'],
testEnvironment: 'jsdom',
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"scripts": {
"chromatic": "chromatic",
"test": "jest",
"test": "jest --coverage",
"test:ci": "jest --onlyChanged",
"start": "start-storybook -p 5000",
"dev": "concurrently --kill-others \"npm run watch-css\" \"npm run start\"",
Expand Down Expand Up @@ -50,6 +50,8 @@
"@storybook/preset-typescript": "^1.2.0",
"@storybook/react": "^5.2.8",
"@storybook/storybook-deployer": "^2.8.5",
"@testing-library/jest-dom": "^5.11.1",
"@testing-library/react": "^10.4.7",
"@types/enzyme": "^3.10.4",
"@types/enzyme-adapter-react-16": "^1.0.5",
"@types/jest": "^24.0.24",
Expand Down
5 changes: 0 additions & 5 deletions scripts/setupTest.js

This file was deleted.

12 changes: 12 additions & 0 deletions scripts/setupTest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import '@testing-library/jest-dom';
const Enzyme = require('enzyme');
const EnzymeAdapter = require('enzyme-adapter-react-16');
const ReactTestingLibrary = require('@testing-library/react');

// Setup enzyme's react adapter
Enzyme.configure({ adapter: new EnzymeAdapter() });

// Configure React Testing Library
const { configure } = ReactTestingLibrary;

configure({ testIdAttribute: 'data-test' });

0 comments on commit ed8a2a4

Please sign in to comment.