Skip to content

Commit

Permalink
reworks test configurations to allow for lerna run test
Browse files Browse the repository at this point in the history
adds coverage reports
replaces .babelrc with package.json config in core
adds new travis build
  • Loading branch information
christopher-johnson committed Dec 1, 2018
1 parent 79b7435 commit e8143f1
Show file tree
Hide file tree
Showing 12 changed files with 134 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ node_modules/
.pnp.js

# testing
/coverage
coverage

# production
lib
Expand Down
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
language: node_js
node_js:
- 'node'
- "8"
before_script:
- cd minimal_redux_poc
- npm install
- cd packages/mirador3-core
- npm install
- cd ../mirador3-app
- cd ../..
- lerna run build
- lerna run test
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,27 @@
# research-and-demos
Proofs of concept for Mirador 3

1. git clone the repository
2. Navigate to the relevant POC, for example, `cd minimal_redux_poc`
3. Follow the README for that POC.
## lerna
lerna helps manage the Mirador3 "monorepo"

### using lerna

#### `$ lerna bootstrap`

Link local packages together and installs package dependencies

#### `$ lerna run build`

build production packages

#### `$ lerna run start`

start the development mode application

#### `$ lerna run test`

lints and runs tests (use with --stream to see output)

#### `$ lerna run test:coverage`

runs test with coverage
4 changes: 4 additions & 0 deletions packages/mirador3-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
build/
config/
scripts/
coverage/
10 changes: 0 additions & 10 deletions packages/mirador3-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,6 @@ Your app is ready to be deployed!

See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Learn More

You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
Expand Down
44 changes: 44 additions & 0 deletions packages/mirador3-app/jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"coverageDirectory": "<rootDir>/coverage",
"coverageReporters": ["html"],
"resolver": "jest-pnp-resolver",
"setupFiles": [
"jest-canvas-mock"
],
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
]
}
49 changes: 5 additions & 44 deletions packages/mirador3-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@
"workbox-webpack-plugin": "3.6.3"
},
"scripts": {
"lint": "node_modules/.bin/eslint ./",
"start": "node scripts/start.js",
"build": "node scripts/build.js",
"test": "node scripts/test.js"
"test": "npm run lint && jest -c jest.json",
"test:watch": "jest -c jest.json --watch",
"test:coverage": "jest -c jest.json --coverage"
},
"eslintConfig": {
"extends": "react-app"
Expand All @@ -83,49 +86,7 @@
"not ie <= 11",
"not op_mini all"
],
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"resolver": "jest-pnp-resolver",
"setupFiles": [
"jest-canvas-mock"
],
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
]
},
"babel": {
"babel": {
"presets": [
"react-app"
]
Expand Down
52 changes: 0 additions & 52 deletions packages/mirador3-app/scripts/test.js

This file was deleted.

5 changes: 0 additions & 5 deletions packages/mirador3-core/.babelrc

This file was deleted.

1 change: 1 addition & 0 deletions packages/mirador3-core/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
lib/
config/
coverage/
42 changes: 42 additions & 0 deletions packages/mirador3-core/jest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"automock": false,
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"coverageDirectory": "<rootDir>/coverage",
"coverageReporters": ["html"],
"resolver": "jest-pnp-resolver",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
]
}
46 changes: 6 additions & 40 deletions packages/mirador3-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
"repository": "https://github.com/ProjectMirador/research-and-demos/mirador3-core",
"scripts": {
"lint": "node_modules/.bin/eslint ./",
"test": "npm run build && npm run lint && node_modules/.bin/jest",
"test:watch": "npm test -- --watch",
"test": "npm run lint && jest -c jest.json",
"test:watch": "jest -c jest.json --watch",
"test:coverage": "jest -c jest.json --coverage",
"build": "node_modules/.bin/webpack",
"build:watch": "node_modules/.bin/webpack --watch"
},
Expand Down Expand Up @@ -45,44 +46,9 @@
"webpack": "^4.24.0",
"webpack-cli": "^3.1.2"
},
"jest": {
"automock": false,
"setupTestFrameworkScriptFile": "<rootDir>/src/setupTests.js",
"collectCoverageFrom": [
"src/**/*.{js,jsx,ts,tsx}",
"!src/**/*.d.ts"
],
"resolver": "jest-pnp-resolver",
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.{js,jsx,ts,tsx}",
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,ts,tsx}"
],
"testEnvironment": "jsdom",
"testURL": "http://localhost",
"transform": {
"^.+\\.(js|jsx|ts|tsx)$": "<rootDir>/node_modules/babel-jest",
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|ts|tsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
},
"transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$",
"^.+\\.module\\.(css|sass|scss)$"
],
"moduleNameMapper": {
"^react-native$": "react-native-web",
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
},
"moduleFileExtensions": [
"web.js",
"js",
"web.ts",
"ts",
"web.tsx",
"tsx",
"json",
"web.jsx",
"jsx",
"node"
"babel": {
"presets": [
"@babel/preset-env"
]
}
}

0 comments on commit e8143f1

Please sign in to comment.