Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Simplify test suite and use vrtest for regressions #6122

Merged
merged 16 commits into from
Feb 12, 2017
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
"transform-dev-warning"
],
"env": {
"coverage": {
"plugins": [
["istanbul"]
]
},
"test": {
"sourceMaps": "both"
},
Expand Down
5 changes: 0 additions & 5 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
node_modules
/build
/dist
/flow
/docs/site/build
/packages/**/lib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we still need it. Same for build. Well, that's only useful for people how publish to npm/work on the build process.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. We can put them back then.

/packages/icon-builder
/packages/material-ui-codemod/modules/v0.15.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same, useful when I'm deploying the docs to firebase.

/src/svg-icons
/test/coverage
/test/regressions/site/build
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ node_modules

# Editor files
.idea
tmp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Empty ending line?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 still getting used to my new editor haha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OT: What have you switched from / to?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sublime text to vscode

16 changes: 0 additions & 16 deletions .istanbul.yml

This file was deleted.

30 changes: 0 additions & 30 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Place your settings in this file to overwrite default and user settings.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you forget or intentionally commit settings file?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Accident, thanks.

{
"flow.useNPMPackagedFlow": true,
"flow.enabled": true
}
35 changes: 17 additions & 18 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
machine:
node:
version: 6.1.0
version: 6.9.5
services:
- docker
environment:
YARN_VERSION: 0.18.1
PATH: "${PATH}:${HOME}/.yarn/bin:${HOME}/${CIRCLE_PROJECT_REPONAME}/node_modules/.bin"
general:
branches:
ignore:
- master
- gh-pages
artifacts:
- test/regressions/screenshots/output
- tmp/output

dependencies:
pre:
- |
if [[ ! -e ~/.yarn/bin/yarn || $(yarn --version) != "${YARN_VERSION}" ]]; then
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version $YARN_VERSION
fi
- cd test && docker-compose up -d chrome && cd ../
override:
- yarn install
- cd docs/site && yarn install && cd ../../
- cd test/regressions/site && yarn install && cd ../../../
cache_directories:
- ~/.yarn
- ~/.cache/yarn
- ~/.yarn-cache
- ~/.docker
override:
- yarn install --cache-folder ~/.yarn-cache --pure-lockfile
- cd docs/site && yarn install --cache-folder ~/.yarn-cache && cd ../../
- mkdir -p ~/.docker
- if [[ -e ~/.docker/hub.tar ]]; then docker load -i ~/.docker/hub.tar; fi
- if [[ -e ~/.docker/node-chrome.tar ]]; then docker load -i ~/.docker/node-chrome.tar; fi
- docker-compose up -d
- if [[ ! -e ~/.docker/hub.tar ]]; then docker save selenium/hub:3.0.1 > ~/.docker/hub.tar; fi
- if [[ ! -e ~/.docker/node-chrome.tar ]]; then docker save selenium/node-chrome:3.0.1 > ~/.docker/node-chrome.tar; fi

test:
override:
- ./scripts/run-travis-tests.sh && ./scripts/export-coverage.sh
- ./scripts/run-travis-tests.sh && bash <(curl -s https://codecov.io/bash)

8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
hub:
image: selenium/hub:3.0.1
ports:
- 4444:4444
chrome:
image: selenium/node-chrome:3.0.1
links:
- hub
39 changes: 21 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "material-ui-build",
"private": true,
"author": "Material-UI Team",
"version": "1.0.0-alpha.2",
"version": "1.0.0-alpha.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"description": "Material Design UI components built with React",
"main": "./src/index.js",
"keywords": [
Expand Down Expand Up @@ -34,14 +34,11 @@
"lint": "eslint . --cache && echo \"eslint: no lint errors\"",
"lint:find-rules": "eslint-find-rules -u .eslintrc.js",
"prebuild": "npm run clean:build",
"test": "node test mocha",
"test:watch": "node test mocha -w",
"test:coverage": "istanbul cover test/index.js -- mocha",
"test:karma": "node test karma",
"test:e2e": "node test e2e -e chrome_51",
"test:e2e:local": "node test e2e -l -e chrome",
"test:e2e:all": "node test e2e -e chrome_51,safari_9,firefox_46,ie_edge,ie_10",
"test:regressions": "node test regressions -l",
"test": "cross-env NODE_ENV=test mocha",
"test:watch": "cross-env NODE_ENV=test mocha -w",
"test:coverage": "cross-env NODE_ENV=test BABEL_ENV=coverage nyc mocha && nyc report -r lcovonly",
"test:karma": "cross-env NODE_ENV=test karma start test/karma.conf.js --single-run",
"test:regressions": "webpack --config test/regressions/webpack.config.js && vrtest run --config test/vrtest.config.js",
"flow": "flow"
},
"peerDependencies": {
Expand All @@ -67,6 +64,7 @@
"babel-core": "^6.22.1",
"babel-eslint": "^7.1.1",
"babel-loader": "^6.2.10",
"babel-plugin-istanbul": "^4.0.0",
"babel-plugin-react-remove-properties": "^0.2.3",
"babel-plugin-transform-dev-warning": "^0.1.0",
"babel-plugin-transform-react-constant-elements": "^6.22.0",
Expand All @@ -79,10 +77,7 @@
"babel-preset-stage-1": "^6.22.0",
"babel-register": "^6.22.0",
"babel-runtime": "^6.22.0",
"blink-diff": "^1.0.13",
"chai": "^3.5.0",
"commander": "^2.9.0",
"coveralls": "^2.11.15",
"cross-env": "^3.1.4",
"doctrine": "^2.0.0",
"enzyme": "^2.7.0",
Expand All @@ -100,8 +95,6 @@
"flow-bin": "^0.38.0",
"fs-extra": "^2.0.0",
"glob": "^7.1.1",
"http-server": "^0.9.0",
"istanbul": "^1.1.0-alpha.1",
"jsdom": "^9.9.1",
"json-loader": "^0.5.4",
"karma": "^1.4.0",
Expand All @@ -112,11 +105,8 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^2.0.1",
"mocha": "^3.2.0",
"ngrok": "^2.2.5",
"nightwatch": "^0.9.12",
"nodemon": "^1.11.0",
"nyc": "^10.1.2",
"phantomjs-prebuilt": "^2.1.14",
"png-crop": "0.0.1",
"random-words": "0.0.1",
"raw-loader": "^0.5.1",
"react": "^15.4.2",
Expand All @@ -129,6 +119,19 @@
"recursive-readdir-sync": "^1.0.6",
"rimraf": "^2.5.2",
"sinon": "^1.17.7",
"url-loader": "^0.5.7",
"vrtest": "0.1.1-beta.2",
"webfontloader": "^1.6.27",
"webpack": "^1.14.0"
},
"nyc": {
"include": [
"src/**/*.js"
],
"exclude": [
"**/*.spec.js"
],
"sourceMap": false,
"instrument": false
}
}
2 changes: 1 addition & 1 deletion scripts/run-travis-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ npm run lint
npm run flow
npm run test:coverage
npm run test:karma
npm run test:regressions
DOCKER_TEST_URL=http://$(ip addr show docker0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1):3090 npm run test:regressions

if git log ${TRAVIS_COMMIT_RANGE} | grep -Ei '\[codemod\]'; then
cd packages/material-ui-codemod && npm install && npm test
Expand Down
20 changes: 6 additions & 14 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ Please familiarise yourself with these if you plan on contributing! :+1:
- [enzyme](https://github.com/airbnb/enzyme)
- [jsdom](https://github.com/tmpvar/jsdom)
- [karma](https://github.com/karma-runner/karma)
- [docker](https://github.com/docker/docker)
- [nightwatch](https://github.com/nightwatchjs/nightwatch)
- [chai](https://github.com/chaijs/chai)
- [sinon](https://github.com/sinonjs/sinon)
- [docker](https://github.com/docker/docker)
- [vrtest](https://github.com/nathanmarks/vrtest)

## Commands

Expand Down Expand Up @@ -54,12 +54,6 @@ In the end, components are going to be used in a real browser.
The DOM is just one dimension of that environment,
so we also need to take into account the rendering engine.

#### Run the e2e selenium tests.
`npm run test:e2e`

First, we have an end-to-end test suite using [nightwatch](https://github.com/nightwatchjs/nightwatch). As the name suggests, it allows testing all the feature of
a real browser.

#### Run the visual regression tests
`npm run test:regressions`

Expand All @@ -72,22 +66,20 @@ Next, we are using [docker](https://github.com/docker/docker) to take screenshot

The visual regression tests suite has a hard dependency on [docker](https://github.com/docker/docker).
You need to **install** it, then run the following commands:

```sh
cd test
docker-compose up
docker-compose up -d
```

#### Update the baseline

You can update the baseline images by running the following command:
`npm run test:regressions -- -c`

You can have a look at the `/test/cli.js` file to get more details on the available options.
`npm run test:regressions -- --record`

## Writing Tests

For all unit tests, please use the [shallow renderer](https://github.com/airbnb/enzyme/blob/master/docs/api/shallow.md) from `enzyme` unless the Component being tested requires a DOM. [Here's](https://github.com/callemall/material-ui/blob/master/src/Avatar/Avatar.spec.js) a small shallow rendered test to get you started.

If the Component being unit tested requires a DOM, you can use the [mount api](https://github.com/airbnb/enzyme/blob/master/docs/api/mount.md) from `enzyme`. For some operations, you may still need to use the React test utils, but try to use the `enzyme` API as much as possible.

Stick to test assertions such as `assert.strictEqual` and `assert.ok`. This helps keep tests simple and readable.
Stick to test assertions such as `assert.strictEqual` and `assert.ok`. This helps keep tests simple and readable.
82 changes: 0 additions & 82 deletions test/cli.js

This file was deleted.

14 changes: 0 additions & 14 deletions test/docker-compose.yml

This file was deleted.

Loading