Skip to content
This repository was archived by the owner on Jan 14, 2025. It is now read-only.

test: capture screenshots with capture-chrome, and diff them with resemble #3

Merged
merged 14 commits into from
Mar 10, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
@@ -0,0 +1,5 @@
{
"presets": [
"es2015"
Copy link

Choose a reason for hiding this comment

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

can we also add "react" here? We don't have any jsx files yet, so we can add it then.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think i want to wait, because this babelrc is actually affecting our babel translator for the mocha. So basically this is running on like capture-suite.js

Copy link

@moog16 moog16 Mar 10, 2018

Choose a reason for hiding this comment

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

Ya, but I don't think it affects .js files that don't have JSX in it. It basically compiles the JSX -> JS. Although I'm testing the branch again right now and having issues, but don't think it is related to the .babelrc file.

]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage
.idea
node_modules
.DS_Store
.DS_Store
169 changes: 169 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 10 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
"license": "Apache-2.0",
"scripts": {
"start": "webpack-dev-server --config test/screenshot/webpack.config.js --content-base test/screenshot",
"stop": "./test/screenshot/stop.sh",
"capture": "./node_modules/.bin/mocha --compilers js:babel-core/register --ui tdd test/screenshot/capture-suite.js",
"commitmsg": "validate-commit-msg",
"fix": "eslint --fix packages test",
"lint": "eslint packages test",
"pretest": "npm run lint",
"test": "npm run test:unit",
"posttest": "istanbul report --root coverage text-summary && istanbul check-coverage --lines 95 --statements 95 --branches 95 --functions 95",
"pretest": "npm run lint && npm stop && ./test/screenshot/start.sh",
"test": "npm run test:unit && npm run test:image-diff",
"posttest": "npm stop && istanbul report --root coverage text-summary && istanbul check-coverage --lines 95 --statements 95 --branches 95 --functions 95",
"test:watch": "karma start --auto-watch",
"test:unit": "karma start --single-run"
"test:unit": "karma start --single-run",
"test:image-diff": "./node_modules/.bin/mocha --compilers js:babel-core/register --ui tdd --timeout 15000 test/screenshot/diff-suite.js"
},
"config": {
"validate-commit-msg": {
Expand All @@ -28,12 +31,14 @@
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"capture-chrome": "^2.0.0",
"chai": "^4.1.2",
"css-loader": "^0.28.10",
"eslint": "^3.19.0",
"eslint-config-google": "^0.9.1",
"eslint-plugin-react": "^7.7.0",
"extract-text-webpack-plugin": "^3.0.2",
"fs-readfile-promise": "^3.0.1",
"husky": "^0.14.3",
"istanbul": "^0.4.5",
"istanbul-instrumenter-loader": "^3.0.0",
Expand All @@ -43,6 +48,7 @@
"karma-mocha": "^1.3.0",
"karma-webpack": "^2.0.13",
"mocha": "^5.0.2",
"node-resemble-js": "^0.2.0",
"node-sass": "^4.7.2",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"react": "^16.2.0",
Expand Down
5 changes: 5 additions & 0 deletions test/screenshot/capture-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fullSuite from './full-suite';

fullSuite.forEach((screenshotSuite) => {
screenshotSuite.capture();
});
5 changes: 5 additions & 0 deletions test/screenshot/diff-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import fullSuite from './full-suite';

fullSuite.forEach((screenshotSuite) => {
screenshotSuite.diff();
});
7 changes: 7 additions & 0 deletions test/screenshot/full-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import temporaryPackageSuite from './temporary-package/screenshot-suite';

const fullSuite = [
temporaryPackageSuite,
];

export default fullSuite;
22 changes: 22 additions & 0 deletions test/screenshot/screenshot-suite.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
export default class ScreenshotSuite {
constructor(name, screenshots) {
this.name_ = name;
this.screenshots_ = screenshots;
}

capture() {
suite(this.name_, () => {});

this.screenshots_.forEach((screenshot) => {
screenshot.capture();
});
}

diff() {
suite(this.name_, () => {});

this.screenshots_.forEach((screenshot) => {
screenshot.diff();
});
}
}
Loading