Skip to content

Commit

Permalink
adding jest configs and react-testing-library with extra dom assertio…
Browse files Browse the repository at this point in the history
…ns (draft-js-plugins#1463)

* adding jest configs and react-testing-library with extra dom assertions

* updating travis.yml, using yarn on scripts and ignoring all storybook extensions on jest

* removing yarn version from travis.yml

* using isolated setup file for jest, due to colisions on expect() function with chai assertions

Co-authored-by: Gabriel <[email protected]>
  • Loading branch information
gabrielreisn and Gabriel authored Sep 2, 2020
1 parent d8d07f0 commit 6fb9943
Show file tree
Hide file tree
Showing 6 changed files with 2,277 additions and 34 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"env": {
"browser": true,
"mocha": true,
"jest": true,
"node": true
},
"extends": "airbnb",
Expand Down
15 changes: 11 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
language: node_js
node_js:
- "8"
sudo: false
- "12.13.0"
cache:
yarn: true
directories: node_modules

install:
- yarn install

script:
- npm test
- npm run lint
- yarn test
- yarn test:jest
- yarn lint
18 changes: 18 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/jestHelper.js'],
moduleFileExtensions: ['jsx', 'js'],
transform: {
'^.+\\.(js|jsx)$': 'babel-jest',
},
moduleDirectories: ['node_modules', 'src'],
testPathIgnorePatterns: ['./node_modules/'],
collectCoverageFrom: [],
coveragePathIgnorePatterns: ['.stories.*'],
coverageThreshold: {
global: {},
},
};
1 change: 1 addition & 0 deletions jestHelper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '@testing-library/jest-dom/extend-expect';
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.5.5",
"@storybook/react": "^5.1.11",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/react-hooks": "^3.4.1",
"alex": "^4.0.1",
"animateplus": "^1.4.0",
"autoprefixer": "^6.7.6",
"babel-eslint": "^10.0.3",
"babel-jest": "^26.3.0",
"babel-loader": "^8.0.6",
"babel-plugin-transform-rename-import": "^2.3.0",
"chai": "^3.5.0",
Expand All @@ -55,6 +59,7 @@
"extract-text-webpack-plugin": "^2.0.0",
"flow-bin": "^0.69.0",
"husky": "^3.0.4",
"jest": "^26.4.2",
"jsdom": "^11.3.0",
"linaria": "^1.4.0-alpha.1",
"lint-staged": "^9.2.3",
Expand Down Expand Up @@ -119,13 +124,14 @@
"scripts": {
"alex": "alex README.md",
"build-storybook": "build-storybook",
"lint": "npm run lint:eslint && npm run lint:flow",
"lint": "yarn lint:eslint && yarn lint:flow",
"lint:eslint": "eslint --rule 'mocha/no-exclusive-tests: 2' ./",
"lint:eslint:fix": "eslint --fix --rule 'mocha/no-exclusive-tests: 2' ./",
"lint:flow": "flow status",
"storybook": "start-storybook -p 6006 -s ./stories/public",
"test": "mocha --compilers @babel/register --require testHelper.js \"./*/src/**/__test__/*.js\"",
"test:watch": "npm test -- --watch"
"test:watch": "yarn test -- --watch",
"test:jest": "jest --passWithNoTests"
},
"workspaces": [
"draft-js-alignment-plugin",
Expand Down
Loading

0 comments on commit 6fb9943

Please sign in to comment.