Skip to content

Commit a6b429e

Browse files
committed
feat: add jest snapshot tests
1 parent d7f756a commit a6b429e

File tree

50 files changed

+793
-70
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+793
-70
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { TestRunnerConfig, waitForPageReady } from '@storybook/test-runner';
2+
import { toMatchImageSnapshot } from 'jest-image-snapshot';
3+
4+
const customSnapshotsDir = `${process.cwd()}/__snapshots__`;
5+
6+
const config: TestRunnerConfig = {
7+
setup() {
8+
expect.extend({ toMatchImageSnapshot });
9+
},
10+
11+
async postVisit(page, context) {
12+
await waitForPageReady(page);
13+
14+
await page.evaluate(() => {
15+
const spinners = document.querySelectorAll(
16+
'.spinner-border',
17+
) as unknown as HTMLElement[];
18+
spinners.forEach(spinner => {
19+
spinner.style.display = 'none';
20+
});
21+
});
22+
23+
const image = await page.screenshot();
24+
25+
expect(image).toMatchImageSnapshot({
26+
customSnapshotsDir,
27+
customSnapshotIdentifier: context.id,
28+
});
29+
},
30+
};
31+
32+
export default config;

clients/design-system/package.json

+8-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"artifact": "create-artifact @galaxyops/design-system",
2323
"test": "jest --runInBand",
2424
"test:cov": "jest --coverage --runInBand",
25+
"test:ui": "test-storybook --url http://127.0.0.1:3000",
2526
"watch": "tsc -w",
2627
"lint": "eslint --format visualstudio \"./src/**/*.tsx\" --fix && stylelint \"./src/**/*.scss\" --fix",
2728
"lint:ci": "eslint --format visualstudio \"./src/**/*.tsx\" --fix-dry-run && stylelint \"./src/**/*.scss\" ",
@@ -38,9 +39,9 @@
3839
},
3940
"peerDependencies": {
4041
"@emotion/react": "~11.11.1",
42+
"luxon": "3.3.0",
4143
"react": "^18.2.0",
42-
"react-dom": "^18.2.0",
43-
"luxon": "3.3.0"
44+
"react-dom": "^18.2.0"
4445
},
4546
"dependencies": {
4647
"@fortawesome/fontawesome-svg-core": "^6.5.1",
@@ -56,7 +57,6 @@
5657
"xss": "~1.0.14"
5758
},
5859
"devDependencies": {
59-
"@types/luxon": "~3.2.0",
6060
"@babel/core": "7.23.5",
6161
"@babel/preset-env": "7.23.5",
6262
"@babel/preset-react": "7.23.3",
@@ -70,6 +70,7 @@
7070
"@mui/lab": "~5.0.0-alpha.134",
7171
"@mui/material": "~5.12.2",
7272
"@mui/system": "~5.12.1",
73+
"@playwright/test": "^1.50.1",
7374
"@rollup/plugin-multi-entry": "~6.0.1",
7475
"@storybook/addon-a11y": "7.6.3",
7576
"@storybook/addon-actions": "7.6.3",
@@ -84,6 +85,7 @@
8485
"@storybook/node-logger": "7.6.3",
8586
"@storybook/react": "7.6.3",
8687
"@storybook/react-vite": "7.6.3",
88+
"@storybook/test-runner": "0.16.0",
8789
"@storybook/testing-library": "0.2.2",
8890
"@storybook/theming": "7.6.3",
8991
"@testing-library/dom": "9.3.3",
@@ -93,6 +95,7 @@
9395
"@testing-library/user-event": "14.5.1",
9496
"@types/jest": "29.5.12",
9597
"@types/lodash": "4.17.6",
98+
"@types/luxon": "~3.2.0",
9699
"@types/node": "20.11.25",
97100
"@types/react": "18.2.59",
98101
"@types/react-dom": "18.2.19",
@@ -114,6 +117,7 @@
114117
"glob": "^10.3.10",
115118
"identity-obj-proxy": "~3.0.0",
116119
"jest": "29.7.0",
120+
"jest-image-snapshot": "^6.4.0",
117121
"react": "18.2.0",
118122
"react-day-picker": "8.9.1",
119123
"react-dom": "18.2.0",
@@ -146,4 +150,4 @@
146150
},
147151
"author": "hxtree",
148152
"license": "MIT"
149-
}
153+
}

0 commit comments

Comments
 (0)