Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactor the test directory structure. - Imports the `node` tests into the browser, building with webpack. They are the source of truth. - Run headless chrome in Travis. - Run IE9 in Appveyor. - Use `builder` to parallelize running lint and various tests. - Fixes #7
- Loading branch information
1 parent
0efbd22
commit 53a5ca1
Showing
15 changed files
with
3,606 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,37 @@ | ||
dist: trusty | ||
|
||
language: node_js | ||
|
||
node_js: | ||
- "4" | ||
- "6" | ||
- "7" | ||
- "8" | ||
- "9" | ||
|
||
branches: | ||
only: | ||
- master | ||
|
||
addons: | ||
chrome: stable | ||
|
||
before_install: | ||
# GUI for real browsers. | ||
- export DISPLAY=:99.0 | ||
- sh -e /etc/init.d/xvfb start | ||
# Headless chrome | ||
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost & | ||
|
||
script: | ||
# Output useful info for debugging. | ||
- node --version | ||
- yarn --version | ||
# Tests | ||
- yarn run test | ||
|
||
after_script: | ||
- coveralls < coverage/lcov.info | ||
|
||
cache: | ||
yarn: true | ||
directories: | ||
- node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
Contributing | ||
============ | ||
|
||
Thanks for contributing! | ||
|
||
## Development | ||
|
||
Install the project using `yarn` (which we've standardized on for development): | ||
|
||
```sh | ||
$ yarn install | ||
``` | ||
|
||
`tl;dr` -- Everything you normally need to run is aggregated into: | ||
|
||
```sh | ||
$ yarn run test | ||
$ yarn run benchmark | ||
``` | ||
|
||
(We use `builder` to parallelize things, so tasks may output in different | ||
orders) | ||
|
||
### Testing | ||
|
||
We write one set of tests located in: | ||
|
||
- `tests/node/**.spec.js` | ||
|
||
that run in two very different scenarios: | ||
|
||
#### Node | ||
|
||
The tests are natively run in `node` (hence why they are located in `tests/node` | ||
to begin with) without any transpilation or "build". You can run them with: | ||
|
||
```sh | ||
# Single run | ||
$ yarn run test-node | ||
|
||
# Persistent watch | ||
$ yarn run test-node --watch | ||
``` | ||
|
||
#### Browsers | ||
|
||
The same tests are then imported and built with `webpack` to a test bundle that | ||
can be run in arbitrary browsers. So far in CI, we execute the tests in headless | ||
Chrome on Linux in Travis and IE9-emulated IE11 in Appveyor. | ||
|
||
To run the browser tests on your machine (note: you must already have the | ||
browser you're running installed): | ||
|
||
```sh | ||
# Default: headless chrome | ||
$ yarn run test-browser | ||
# Example: real Chrome + Firefox + Safari | ||
$ yarn run test-browser --browsers Chrome,Firefox,Safari | ||
|
||
# IE9 emulation (on Windows) | ||
$ yarn run test-browser-ie | ||
``` | ||
|
||
### Types | ||
|
||
We validate our TypeScript `index.d.ts` with: | ||
|
||
```sh | ||
$ yarn run test-ts | ||
``` | ||
|
||
### Style | ||
|
||
```sh | ||
$ yarn run eslint | ||
``` | ||
|
||
## Before submitting a PR... | ||
|
||
Before you go ahead and submit a PR, make sure that you have done the following: | ||
|
||
```sh | ||
$ yarn run test | ||
$ yarn run benchmark | ||
``` | ||
|
||
Everything must be correct / pass checks. You should also check the benchmark | ||
stats and make sure that we don't have any significant performance regressions | ||
(check out `master` for a baseline comparison on _your_ machine). | ||
|
||
## Releasing a new version to NPM | ||
|
||
_Only for project administrators_. | ||
|
||
1. Run `npm version patch` (or `minor|major|VERSION`) to run tests and lint, | ||
build published directories, then update `package.json` + add a git tag. | ||
2. Run `npm publish` and publish to NPM if all is well. | ||
3. Run `git push && git push --tags` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Test against this version of Node.js | ||
environment: | ||
matrix: | ||
- nodejs_version: "6" | ||
- nodejs_version: "8" | ||
- nodejs_version: "9" | ||
|
||
# Install scripts. (runs after repo cloning) | ||
install: | ||
- ps: Install-Product node $env:node_version | ||
- yarn install | ||
|
||
# Post-install test scripts. | ||
test_script: | ||
# Output useful info for debugging. | ||
- node --version | ||
- yarn --version | ||
# Run tests | ||
- yarn run test-ie | ||
|
||
# Don't actually build. | ||
build: off | ||
|
||
matrix: | ||
fast_finish: true | ||
|
||
cache: | ||
- node_modules | ||
- "%LOCALAPPDATA%/Yarn" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
'use strict'; | ||
|
||
// Polyfills for IE9 in React 16. | ||
require('core-js/es6/map'); | ||
require('core-js/es6/set'); | ||
require('core-js/es6/weak-map'); | ||
|
||
// Re-use node tests. | ||
const testsContext = require.context('../node', true, /\.spec\.js$/); | ||
testsContext.keys().forEach(testsContext); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
'use strict'; | ||
|
||
module.exports = function(config) { | ||
require('./karma.conf.js')(config); | ||
config.set({ | ||
plugins: config.plugins.concat('karma-ie-launcher'), | ||
browsers: ['IE9'], | ||
customLaunchers: { | ||
IE9: { | ||
base: 'IE', | ||
'x-ua-compatible': 'IE=EmulateIE9' | ||
} | ||
} | ||
}); | ||
}; |
Oops, something went wrong.