Skip to content

Commit d425728

Browse files
authored
Move E2E tests to screenshots based tests (#337)
1 parent 1f58ee9 commit d425728

31 files changed

+1274
-5163
lines changed

.github/workflows/screenshots.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Screenshots
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
test:
7+
name: Lint & Test
8+
runs-on: macos-latest
9+
env:
10+
CI: true
11+
steps:
12+
- name: Checkout Repo
13+
uses: actions/checkout@main
14+
15+
- name: Setup Node.js 14.x
16+
uses: actions/setup-node@main
17+
with:
18+
node-version: 14.x
19+
20+
- name: Install Dependencies
21+
run: yarn --immutable
22+
23+
- name: Install Browsers
24+
run: yarn playwright install chromium
25+
26+
- name: Build packages
27+
run: yarn build
28+
29+
- name: Screenshot tests
30+
run: yarn test:playwright
31+
32+
- uses: actions/upload-artifact@v2
33+
if: failure()
34+
with:
35+
name: test-results
36+
path: test-results/

.github/workflows/validate.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ jobs:
2727
run: yarn lint
2828

2929
- name: Test
30-
run: yarn test
30+
run: yarn test:jest

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ yarn-error.log
55
packages/**/README.md
66
!packages/sprinkles/README.md
77
!packages/integration/README.md
8+
test-results
89

910

1011
.yarn/*

fixtures/themed/src/styles.css.ts

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import {
55
fallbackVar,
66
fontFace,
77
globalFontFace,
8-
keyframes,
9-
globalKeyframes,
108
globalStyle,
119
} from '@vanilla-extract/css';
1210
import { shadow } from './shared.css';
@@ -20,26 +18,7 @@ globalFontFace('MyGlobalComicSans', {
2018
src: 'local("Comic Sans MS")',
2119
});
2220

23-
const slide = keyframes({
24-
'0%': {
25-
transform: 'translateY(-4px)',
26-
},
27-
'100%': {
28-
transform: 'translateY(4px)',
29-
},
30-
});
31-
32-
globalKeyframes('globalSlide', {
33-
'0%': {
34-
transform: 'translateY(-4px)',
35-
},
36-
'100%': {
37-
transform: 'translateY(4px)',
38-
},
39-
});
40-
4121
export const container = style({
42-
animation: `3s infinite alternate globalSlide ease-in-out`,
4322
display: 'flex',
4423
flexDirection: 'column',
4524
gap: vars.space[2],
@@ -81,8 +60,8 @@ export const button = style([
8160
iDunno,
8261
]);
8362

84-
globalStyle(`body ${iDunno}`, {
85-
animation: `3s infinite alternate ${slide} ease-in-out`,
63+
globalStyle(`body ${iDunno}:after`, {
64+
content: "'I am content'",
8665
});
8766

8867
const blankVar1 = createVar();

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
preset: 'jest-puppeteer',
32
setupFilesAfterEnv: ['./jest.setup.ts'],
43
transform: {
54
'\\.tsx?$': ['babel-jest', { configFile: './babel-jest.config.js' }],
65
},
6+
testMatch: ['**/?(*.)+(test).[jt]s?(x)'],
77
};

jest.setup.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
11
import '@testing-library/jest-dom';
2-
3-
jest.setTimeout(30000);

package.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
"start-site": "manypkg run site start",
1414
"build-site": "manypkg run site build",
1515
"postinstall": "yarn dev",
16-
"test": "jest",
16+
"test:jest": "jest",
17+
"test:playwright": "playwright test",
1718
"format": "prettier --write .",
1819
"lint": "manypkg check && prettier --check . && tsc",
1920
"copy-readme-to-packages": "ts-node scripts/copy-readme-to-packages",
@@ -44,17 +45,14 @@
4445
"@changesets/changelog-github": "^0.4.0",
4546
"@changesets/cli": "^2.16.0",
4647
"@manypkg/cli": "^0.17.0",
48+
"@playwright/test": "^1.14.1",
4749
"@preconstruct/cli": "^2.0.1",
4850
"@testing-library/dom": "^7.30.0",
4951
"@testing-library/jest-dom": "^5.11.9",
5052
"@types/jest": "^26.0.20",
51-
"@types/jest-environment-puppeteer": "^4.4.1",
52-
"@types/puppeteer": "^5.4.3",
5353
"babel-jest": "^26.6.3",
5454
"jest": "^26.6.3",
55-
"jest-puppeteer": "^4.4.0",
5655
"prettier": "^2.3.2",
57-
"puppeteer": "^8.0.0",
5856
"ts-node": "^9.1.1",
5957
"typescript": "^4.1.3"
6058
}

playwright.config.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { PlaywrightTestConfig, devices } from '@playwright/test';
2+
3+
const config: PlaywrightTestConfig = {
4+
testMatch: '**/*.playwright.ts',
5+
updateSnapshots: 'none',
6+
expect: {
7+
toMatchSnapshot: {
8+
threshold: 0.1,
9+
},
10+
},
11+
12+
projects: [
13+
{
14+
name: 'Desktop - Chromium',
15+
use: {
16+
browserName: 'chromium',
17+
channel: 'chrome',
18+
viewport: {
19+
width: 1200,
20+
height: 1080,
21+
},
22+
},
23+
},
24+
{
25+
name: 'Mobile - Chromium',
26+
use: {
27+
browserName: 'chromium',
28+
channel: 'chrome',
29+
viewport: {
30+
width: 414,
31+
height: 896,
32+
},
33+
},
34+
},
35+
],
36+
};
37+
export default config;

test-helpers/src/getNodeStyles.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

test-helpers/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export * from './startFixture';
2-
export * from './getNodeStyles';
32
export * from './getStylesheet';
43

54
export const getTestNodes = (fixture: string) =>

0 commit comments

Comments
 (0)