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

Add Snapshot testing #194

Merged
merged 7 commits into from
Nov 20, 2020
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
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ run:
npm run storybook
```

### Storybook Snapshot Testing

To give us more confidence that changes don't unintentionally break the UI, we run [storybook snapshot tests](https://storybook.js.org/docs/react/workflows/snapshot-testing).

You can run them manually as follows:

```bash
npm run test:jest
```

If you intentionally made a change to a component that results in a change
to the output of the storybook snapshots, you can re-generate them using
the following command:

```bash
npm run test:jest -- -u
```

## Contributing

For more information on contributing, see [CONTRIBUTING.md](./CONTRIBUTING.md)
Expand Down
1 change: 1 addition & 0 deletions __mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "test-file-stub";
1 change: 1 addition & 0 deletions __mocks__/styleMock.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = {};
12 changes: 12 additions & 0 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
module.exports = {
presets: [
[
"@babel/preset-env",
{
targets: {
node: "current",
},
},
],
],
};
13 changes: 13 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
transform: {
"^.+\\.svelte$": "svelte-jester",
"^.+\\.js$": "babel-jest",
},
moduleFileExtensions: ["js", "svelte", "json"],
testPathIgnorePatterns: ["/node_modules/", "/public/", "/storybook-static/"],
moduleNameMapper: {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$":
"<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "<rootDir>/__mocks__/styleMock.js",
},
};
13,367 changes: 8,648 additions & 4,719 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@
"start": "sirv public",
"storybook": "start-storybook --static-dir ./public -p 6006",
"test": "npm-run-all format:check lint test:jest",
"test:jest": "jest tests --no-cache",
"test:jest": "jest tests src --no-cache",
"build-glean-metadata": "node scripts/build-glean-metadata.js"
},
"devDependencies": {
"@babel/core": "7.12.3",
"@babel/core": "^7.12.3",
"@babel/plugin-transform-runtime": "7.12.1",
"@babel/preset-env": "7.12.1",
"@babel/preset-env": "^7.12.1",
"@rollup/plugin-commonjs": "15.1.0",
"@rollup/plugin-node-resolve": "9.0.0",
"@storybook/addon-knobs": "6.0.26",
"@storybook/addon-storyshots": "^6.0.28",
"@storybook/addon-storysource": "6.0.26",
"@storybook/svelte": "6.0.26",
"@testing-library/svelte": "^3.0.0",
"babel-jest": "^26.6.3",
"babel-loader": "8.1.0",
"eslint": "7.11.0",
"eslint-config-airbnb-base": "14.2.0",
Expand All @@ -31,7 +34,7 @@
"eslint-plugin-jest": "24.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-svelte3": "2.7.3",
"jest": "26.5.3",
"jest": "^26.5.3",
"lerna": "3.22.1",
"npm-run-all": "4.1.5",
"page": "1.11.6",
Expand All @@ -43,10 +46,11 @@
"rollup-plugin-svelte": "6.0.1",
"rollup-plugin-terser": "7.0.2",
"svelte": "3.29.0",
"svelte-jester": "^1.1.5",
"svelte-loader": "2.13.6"
},
"dependencies": {
"just-throttle": "^1.1.0",
"lodash": "^4.17.20",
"lunr": "^2.3.9",
"marked": "^1.2.2",
"node-fetch": "^2.6.1",
Expand Down
Loading