Skip to content

Commit

Permalink
Add Puppeteer snapshot testing
Browse files Browse the repository at this point in the history
  • Loading branch information
captbaritone committed Jun 29, 2018
1 parent 077fa94 commit d175746
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
"es6": true,
"jest": true
},
"globals": {
"page": true,
"browser": true
},
"rules": {
"no-multiple-empty-lines": [
"error",
Expand Down
6 changes: 6 additions & 0 deletions config/jest.integration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
displayName: "integration-test",
rootDir: "../",
preset: "jest-puppeteer",
testRegex: "\\.integration-test\\.js$"
};
8 changes: 8 additions & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module.exports = {
server: {
// Note: We require the the build be run before these tests.
// TODO: Figure out how to get this command to run the buil.
command: "npm run serve",
port: 8080 // Jest Puppeteer will wait 5000ms for this port to come online.
}
};
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions js/__tests__/baseline.integration-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const { toMatchImageSnapshot } = require("jest-image-snapshot");

expect.extend({ toMatchImageSnapshot });

beforeAll(async () => {
await page.goto(`http://localhost:8080/#{"disableMarquee":true}`);
});

it("should render the default skin", async () => {
expect(await page.screenshot()).toMatchImageSnapshot();
});

it("should render the Topaz skin", async () => {
expect(page).toUploadFile("#webamp-file-input", "./skins/TopazAmp1-2.wsz");
await new Promise(resolve => setTimeout(resolve, 200));
expect(await page.screenshot()).toMatchImageSnapshot();
});
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"travis-tests": "npm run test && npm run build && npm run build-library",
"tdd": "jest --projects config/jest.unit.js --watch",
"format": "prettier --write experiments/**/*.js js/**/*.js css/**/*.css !css/**/*.min.css",
"integration-tests": "npm run build -- --display=errors-only && jest --projects config/jest.integration.js",
"build-skin": "rm skins/base-2.91.wsz && cd skins/base-2.91 && zip -x .* -x 'Skining Updates.txt' -r ../base-2.91.wsz .",
"build-skin-png": "rm skins/base-2.91-png.wsz && cd skins/base-2.91-png && zip -x .* -x 'Skining Updates.txt' -r ../base-2.91-png.wsz .",
"compile-skin": "node scripts/compileSkin.js > css/base-skin.css",
Expand Down Expand Up @@ -78,6 +79,8 @@
"invariant": "^2.2.3",
"jest": "^23.0.0",
"jest-mock-random": "^1.0.2",
"jest-image-snapshot": "^2.4.1",
"jest-puppeteer": "^3.0.1",
"jest-runner-eslint": "^0.4.0",
"jsmediatags": "^3.8.1",
"jszip": "^3.1.3",
Expand Down
Loading

0 comments on commit d175746

Please sign in to comment.