Skip to content

Commit a0dae66

Browse files
committed
(test): add initial test harness
- add 1 simple test for existence of canvas and instance methods - (pkg): test code shouldn't be in the package, just source - currently preferring to keep source and tests co-located - change test script to use jest, and move prev test to test:pub - (ci): change CI to run test and test:pub - configure jest and enzyme for testing usage - make jest importable too - add .babelrc to configure babel-jest - can't use .babelrc.js as babel-jest@23 doesn't support it - jestjs/jest#5324 - can't use .babelrc for babel-loader because babel-loader@6 has some bugs with it and @7 doesn't support webpack@1 - babel/babel-loader#552 - use jest instead of ava mainly because there's less to configure / install (directly at least, still a lot indirectly), it's popular / well-supported in React community, and supports configuration outside of package.json - see agilgur5#33 for some more details (deps): add jest, enzyme, and supporting deps to devDeps - add babel-jest@23 for Babel 6 support - and configure it for .js files due to a jest bug - add canvas-prebuilt@1 to support jest's jsdom v11 - canvas is used by jsdom for, well, canvas interactions - add enzyme-adapter-react-16 to configure Enzyme with React 16 - upgrade to React 16 in devDeps bc adapter-react-15 requires react-test-renderer and no drawbacks in upgrading
1 parent 8f0ca6a commit a0dae66

8 files changed

+8965
-1287
lines changed

.babelrc

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"presets": [
3+
"es2015",
4+
"react",
5+
"stage-2"
6+
]
7+
}

.travis.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ node_js: '8.9'
44

55
before_script: npm run lint
66
script: npm test
7+
after_script: npm run test:pub

jest.config.js

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
moduleNameMapper: {
3+
// allow importing of Jest as an ES Module (https://github.com/facebook/jest/pull/7571#issuecomment-498634094)
4+
'^jest$': '<rootDir>/test-utils/jest-export.js'
5+
},
6+
setupFilesAfterEnv: [
7+
// configure enzyme w/ react adapter
8+
'<rootDir>/test-utils/configure-enzyme.js'
9+
],
10+
transform: {
11+
// use babel-jest@23 for babel@6 support (https://github.com/facebook/jest/issues/8230#issuecomment-479470547)
12+
'\\.js$': require.resolve('babel-jest')
13+
}
14+
}

0 commit comments

Comments
 (0)