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

chore: refactor e2e tests to playwright #5080

Open
wants to merge 166 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
69e21f1
chore: setup playwright
mahdikhashan Mar 1, 2024
9a1b7e7
chore: disable parallel test running
mahdikhashan Mar 1, 2024
e690789
feat: remove example test from playwright setup step
mahdikhashan Mar 1, 2024
f371ae6
test: refactor test/e2e/states.test.js
mahdikhashan Mar 1, 2024
512e9ef
chore: setup playwright
mahdikhashan Mar 1, 2024
c451168
chore: rebase on master
mahdikhashan Jun 15, 2024
aa8ebcc
chore: add playwright after it was removed by merge conflicts
mahdikhashan May 12, 2024
764d300
chore: rebase on master
mahdikhashan Jun 15, 2024
b508045
test: remove old snapshots
mahdikhashan May 12, 2024
3882b7b
fix: move `playwright` requires after `webpack` to fix eslint warning
mahdikhashan May 12, 2024
a7adbfa
test: snapshots for `stats.test.js`
mahdikhashan May 12, 2024
124d006
test: move `progress.test.js` to playwright
mahdikhashan Jun 1, 2024
17d8da7
test: move `allowed-hosts.test.js` to playwright
mahdikhashan Jun 7, 2024
8b6536d
test: move `app.test.js` to playwright
mahdikhashan Jun 8, 2024
d753fb5
test: move `client.test.js` to playwright
mahdikhashan Jun 8, 2024
b2e867f
test: rename `client.test.js` to `client-refactored.test.js`
mahdikhashan Jun 8, 2024
c76af2d
test: move `client-reconnect.test.js` to Playwright
mahdikhashan Jun 8, 2024
35b555e
test: move `entry.test.js` to Playwright
mahdikhashan Jun 9, 2024
9957ee3
test: move `headers.test.js` to Playwright
mahdikhashan Jun 9, 2024
46d2120
test: move `history-api-fallback.test.js` to Playwright
mahdikhashan Jun 9, 2024
a163664
test: move `hot-and-live-reload.test.js` to Playwright
mahdikhashan Jun 9, 2024
9b11e01
test: move `ipc.test.js` to Playwright
mahdikhashan Jun 9, 2024
6ae0b39
test: move `web-socker-server.test.js` to Playwright
mahdikhashan Jun 9, 2024
7f54b1e
test: move `target.test.js` to Playwright
mahdikhashan Jun 9, 2024
72905b7
test: move `range-header.test.js` to Playwright
mahdikhashan Jun 9, 2024
fb4534c
test: move `range-header.test.js` to Playwright
mahdikhashan Jun 11, 2024
69fbd95
test: move `range-header.test.js` to Playwright
mahdikhashan Jun 11, 2024
a9f7e90
test: move `module-federation.test.js` to Playwright
mahdikhashan Jun 11, 2024
c5804d1
test: move `lazy-compilation.test.js` to Playwright
mahdikhashan Jun 11, 2024
44730ee
test: move `logging.test.js` to Playwright
mahdikhashan Jun 12, 2024
ed26d7a
test: move `multi-compiler.test.js` to Playwright
mahdikhashan Jun 12, 2024
e2b6f79
test: move `watch-files.test.js` to Playwright
mahdikhashan Jun 13, 2024
ed33c1d
test: move `watch-files.test.js` to Playwright
mahdikhashan Jun 13, 2024
01975fd
test: move `server-and-client-transport.test.js` to Playwright
mahdikhashan Jun 14, 2024
c35a665
test: move `server.test.js` to Playwright
mahdikhashan Jun 14, 2024
6e32b09
test: move `setup-exit-signals.test.js` to Playwright
mahdikhashan Jun 14, 2024
0f6d526
chore: add `jest-mock`
mahdikhashan Jun 15, 2024
c6866ce
test: failing tests
mahdikhashan Jun 15, 2024
4a434cf
chore: remove extra config
mahdikhashan Jun 15, 2024
b24cac0
chore: update playwright config
mahdikhashan Jul 2, 2024
391243b
fix: lint error
mahdikhashan Jul 2, 2024
ba581f1
fix: lint error
mahdikhashan Jul 2, 2024
f2b5215
fix: lint error
mahdikhashan Jul 2, 2024
b004d29
fix: revert fixture
mahdikhashan Jul 2, 2024
ac7e66f
feat: remove e2e for puppeteer path
mahdikhashan Jul 2, 2024
efed0ab
chore: rename playwright tests path to `e2e`
mahdikhashan Jul 2, 2024
194efc8
feat: move tests from `e2e-playwright` to `e2e`
mahdikhashan Jul 2, 2024
2422c38
feat: move tests from `e2e-playwright` to `e2e`
mahdikhashan Jul 2, 2024
a1db5bb
chore: ignore tests flagged with `*.ignore.*`
mahdikhashan Jul 2, 2024
8b5a432
chore: ignore spell checking for snapshots
mahdikhashan Jul 2, 2024
770dfcf
chore: ignore e2e tests flagged with `.ignore.`
mahdikhashan Jul 2, 2024
b712f5d
chore: update playwright tests command to be `test:e2e` instead of `t…
mahdikhashan Jul 2, 2024
ca440a7
ci: update github action pipeline by adding playwright tests
mahdikhashan Jul 2, 2024
0198183
chore: add `commitlint` to cspell.json words
mahdikhashan Jul 2, 2024
451c63e
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 2, 2024
fa2f080
fix: prettify `hot-and-live-reload.test.js` file
mahdikhashan Jul 2, 2024
fc79cef
fix: prettify multiple tests
mahdikhashan Jul 2, 2024
be142a2
chore: ignore e2e tests in jest tests coverage run
mahdikhashan Jul 2, 2024
94c0398
ci: remove sharing option for playwright
mahdikhashan Jul 3, 2024
ad847ec
ci: ignore snapshots
mahdikhashan Jul 3, 2024
2b9a487
ci: add caching for snapshots
mahdikhashan Jul 3, 2024
222d64c
ci: remove ignore snapshots
mahdikhashan Jul 3, 2024
ad6e3e0
ci: prevent failing fast for all jobs if any fails
mahdikhashan Jul 3, 2024
a19f9a8
feat: add playwright test method
mahdikhashan Jul 19, 2024
f710750
feat: add custom matcher for playwright
mahdikhashan Jul 19, 2024
5cd5658
feat: update playwright config
mahdikhashan Jul 19, 2024
1b662b8
feat: replace jest with sinon
mahdikhashan Jul 19, 2024
5542e00
feat: update packages
mahdikhashan Jul 19, 2024
d2de702
feat: regenerate snapshots
mahdikhashan Jul 19, 2024
2194b0e
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 22, 2024
297028b
ci: remove update-snapshot step
mahdikhashan Jul 22, 2024
6fa543c
chore: add jsdoc types to playwright config
mahdikhashan Jul 22, 2024
3a9d14b
chore: add `isCI` to the config
mahdikhashan Jul 22, 2024
c3a2f7c
chore: add `MAX_RETRIES` to config file
mahdikhashan Jul 22, 2024
ae857cd
chore: move snapshots to `snpas` folder
mahdikhashan Jul 22, 2024
42aad22
chore: move snapshots to `snpas` folder
mahdikhashan Jul 22, 2024
73db1e0
feat: add `rgba` word
mahdikhashan Jul 22, 2024
ea20ee7
feat: update labels, add a flaky and a mistake in snapshot
mahdikhashan Jul 24, 2024
dacc639
feat: remove eslint comment and update labels
mahdikhashan Jul 24, 2024
c87f84f
chore: fix `net::ERR_HTTP2_PROTOCOL_ERROR` failure on ci
mahdikhashan Jul 24, 2024
73c7b04
fix: lint error
mahdikhashan Jul 24, 2024
0aba203
feat: update labels for `host.test.js`
mahdikhashan Jul 24, 2024
c4233e1
feat: update labels for `overlay.test.js`
mahdikhashan Jul 24, 2024
bf11adb
feat: update labels for `options-middleware.test.js`
mahdikhashan Jul 24, 2024
76a469e
feat: remove redundant `beforeAll` in `web-socket-communication.test.js`
mahdikhashan Jul 24, 2024
b184afe
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 25, 2024
3da63fe
fix: `api.test.js` test work duplicate in inner scope
mahdikhashan Jul 26, 2024
2296ca0
chore: rename snapshot path to look similar existing puppeteer one
mahdikhashan Jul 26, 2024
81cd13e
chore: pass custom extended name to snapshots generated by `toMatchSn…
mahdikhashan Jul 26, 2024
ec5fa86
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 27, 2024
965ea9f
chore: check the argument of custom matcher to be an array
mahdikhashan Jul 27, 2024
f0a9f89
feat: add a custom test with `done` callback
mahdikhashan Jul 27, 2024
480b502
fix: `static-directory.test.js`
mahdikhashan Jul 27, 2024
f53c614
chore: add jsdoc and improve argument handling
mahdikhashan Jul 27, 2024
215fb24
feat: update `allowed-hosts.test.js` test suite using custom test object
mahdikhashan Jul 27, 2024
540c07b
ci: fix longpath error on windows
mahdikhashan Jul 27, 2024
77dd4ea
ci: add longpaths
mahdikhashan Jul 27, 2024
b1dd12c
feat: update `compress.test.js` and comment failing test-case
mahdikhashan Jul 27, 2024
0ecb064
feat: update `api.test.js`
mahdikhashan Jul 27, 2024
f1cb666
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 28, 2024
375665a
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Jul 28, 2024
c3f7b16
feat: update `app.test.js`
mahdikhashan Jul 28, 2024
ab7cf84
feat: update `bonjour.test.js`
mahdikhashan Jul 28, 2024
ef8a227
feat: update `built-in-routes.test.js`
mahdikhashan Jul 28, 2024
954904b
feat: update `built-in-routes.test.js`
mahdikhashan Jul 28, 2024
92f6156
feat: update `client.test.js`
mahdikhashan Jul 28, 2024
c85de43
feat: update `client-reconnect.test.js`
mahdikhashan Jul 28, 2024
999a8bd
feat: update `entry.test.js`
mahdikhashan Jul 28, 2024
7c1bee7
feat: update `headers.test.js`
mahdikhashan Jul 28, 2024
5f0de61
feat: remove old snap folder
mahdikhashan Jul 30, 2024
12799c6
feat: update snapshot folder and refactor tests
mahdikhashan Jul 30, 2024
c120892
fix: duplicate title issue
mahdikhashan Jul 30, 2024
5e91dd7
fix: remove extra comment
mahdikhashan Jul 30, 2024
cf67985
fix: remove `204` from response status
mahdikhashan Jul 30, 2024
45ec116
chore: fix CI
snitin315 Jul 31, 2024
63670d9
chore: fix CI
snitin315 Jul 31, 2024
64bb8ea
chore: fix CI
snitin315 Jul 31, 2024
ee29b46
test: add host test snaps
snitin315 Jul 31, 2024
943e397
test: fix allowed-hosts test
snitin315 Jul 31, 2024
210ff8a
test: update api test
snitin315 Jul 31, 2024
fc53905
test: update lazy-compilation test
snitin315 Jul 31, 2024
bbb31a4
test: update snaps
snitin315 Jul 31, 2024
c5b9473
chore: udpate playwright config
snitin315 Jul 31, 2024
383bbc9
chore: fix tests on windows
snitin315 Jul 31, 2024
4b07fcc
fix: spelling lint job
mahdikhashan Jul 31, 2024
5142e7a
fix: lint job
mahdikhashan Jul 31, 2024
8a9c533
fix: ignore foo.js in overlay-config fixture
mahdikhashan Jul 31, 2024
1cd209d
fix: ignore foo.js in overlay-config fixture
mahdikhashan Jul 31, 2024
9bc2602
fix: lint job
mahdikhashan Jul 31, 2024
e17e676
fix: lint job
mahdikhashan Jul 31, 2024
f1f47a5
fix: lint job
mahdikhashan Jul 31, 2024
77b6523
chore: fix overlay tests
snitin315 Aug 2, 2024
c8815ad
chore: udpate configs
snitin315 Aug 2, 2024
3dfe585
chore: fix overlay tests
snitin315 Aug 3, 2024
a7b204c
chore: skip failing E2Es
snitin315 Aug 3, 2024
d7b92d8
fix: label overlay as slow test
mahdikhashan Aug 3, 2024
fee0ba7
fix: skip `should not show initially, then show on an error, then hid…
mahdikhashan Aug 3, 2024
ef3f14c
fix: `history-api-fallback.test.js` test
mahdikhashan Aug 3, 2024
a2632ae
chore: label `server.test.js` test
mahdikhashan Aug 3, 2024
176b747
chore: label `history-api-fallback.test.js` test
mahdikhashan Aug 3, 2024
24fc9f7
chore: remove annotations
snitin315 Aug 4, 2024
f4c7d08
chore: fix tests on windows
snitin315 Aug 4, 2024
6df1555
chore: fix tests on windows
snitin315 Aug 4, 2024
7a78abd
chore: fix tests on windows
snitin315 Aug 4, 2024
9e470b5
chore: fix tests on windows
snitin315 Aug 4, 2024
9998d51
chore: fix tests on windows
snitin315 Aug 4, 2024
ead0cf8
chore: fix tests on windows
snitin315 Aug 4, 2024
a6a9ceb
chore: add code coverage
mahdikhashan Aug 4, 2024
3f2f662
fix: apply prettier
mahdikhashan Aug 4, 2024
790a871
fix: code coverage
mahdikhashan Aug 4, 2024
6b347ef
chore: prepend nyc to e2e test command
mahdikhashan Aug 4, 2024
b101a6d
chore: update package.json
snitin315 Aug 5, 2024
547f7db
Merge branch 'master' into issue-2843/refactor-e2e-tests-from-puppete…
mahdikhashan Aug 9, 2024
3105fe8
fix: remove lock
mahdikhashan Aug 9, 2024
78e4048
fix: update lock
mahdikhashan Aug 9, 2024
5e2391c
feat: revert skipped test-case
mahdikhashan Aug 9, 2024
c42847a
fix: remove comment
mahdikhashan Aug 9, 2024
ecb160a
fix: remove comment
mahdikhashan Aug 9, 2024
c049129
fix: `static-directory.test.js` flaky test-case
mahdikhashan Aug 9, 2024
d83e240
fix: `static-directory.test.js` test
mahdikhashan Aug 9, 2024
ff50b55
chore: disable retries
mahdikhashan Aug 9, 2024
02bd9e0
chore: disable headless on ci
mahdikhashan Aug 9, 2024
e54f61e
chore: disable headless on ci
mahdikhashan Aug 9, 2024
80bf569
chore: add nyc_output to .gitignore
mahdikhashan Aug 19, 2024
5a37b5d
feat: merge master into branch
mahdikhashan Aug 19, 2024
1c0b48f
feat: update tests
mahdikhashan Aug 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"swiftshader",
"hoge",
"subsubcomain",
"commitlint",
"noselect"
],
"ignorePaths": [
Expand All @@ -77,6 +78,7 @@
"package-lock.json",
"node_modules",
"coverage",
"*.log"
"*.log",
"*-snapshots"
]
}
3 changes: 3 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ node_modules
examples/**/main.js
examples/client/trusted-types-overlay/app.js
test/fixtures/reload-config/foo.js

# ignore tests files
**/*.ignore.*
37 changes: 31 additions & 6 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,18 @@ on:
- next
- v4

workflow_call:
inputs:
update-snapshots:
description: "Update snapshots?"
type: boolean

workflow_dispatch:
inputs:
update-snapshots:
description: "Update snapshots?"
type: boolean
Copy link
Member

Choose a reason for hiding this comment

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

Let's not add this. Tests should ideally fail if snapshots are not in sync with the master branch, this would let user bypass failing CI.


permissions:
contents: read

Expand Down Expand Up @@ -67,6 +79,7 @@ jobs:
name: Test - ${{ matrix.os }} - Node v${{ matrix.node-version }}, Webpack ${{ matrix.webpack-version }} (${{ matrix.shard }})

strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
node-version: [18.x, 20.x, 22.x]
Expand Down Expand Up @@ -97,12 +110,6 @@ jobs:
node ./scripts/prepare-test-for-old-node.js
if: matrix.node-version == '18.x'

- name: Setup firefox
if: matrix.os != 'windows-latest'
uses: browser-actions/setup-firefox@latest
with:
firefox-version: latest

- name: Link webpack-dev-server
run: |
cp -R client tmp-client
Expand All @@ -119,6 +126,24 @@ jobs:
run: npm run test:coverage -- --ci --shard=${{ matrix.shard }}
if: matrix.node-version != '18.x'

- name: Install Playwright browsers and dependencies
run: npx playwright install --with-deps

- name: Set up cache
id: cache
uses: actions/cache@v4
with:
key: cache/${{github.repository}}/${{github.ref}}
restore-keys: cache/${{github.repository}}/refs/heads/master
path: .test/**

- name: Initialize snapshots
if: ${{steps.cache.outputs.cache-hit != 'true' || inputs.update-snapshots == 'true'}}
run: npx playwright test --update-snapshots

- name: Run E2E tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:e2e
Copy link
Member

Choose a reason for hiding this comment

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

Remove the steps at line 121 and 125, also this should be:

Suggested change
- name: Run E2E tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:e2e
- name: Run E2E tests for webpack version ${{ matrix.webpack-version }}
run: npm run test:e2e -- --shard=${{ matrix.shard }}

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

after removing update snapshot step, it still does not work as expected. I'm not sure but I'll try to set a specific folder for snaps.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I set a specific folder for tests and now its working.


- name: Submit coverage data to codecov
uses: codecov/codecov-action@v4
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,7 @@ test/fixtures/watch-files-config/public/assets/non-exist.txt
test/fixtures/reload-config/main.css
test/fixtures/reload-config-2/main.css
!/test/fixtures/static-config/public/node_modules
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
5 changes: 4 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ module.exports = {
"<rootDir>/test/",
"<rootDir>/client/",
],
testPathIgnorePatterns: ["<rootDir>/bin/this/process-arguments.js"],
testPathIgnorePatterns: [
"<rootDir>/bin/this/process-arguments.js",
"<rootDir>/test/e2e",
],
snapshotResolver: "<rootDir>/test/helpers/snapshotResolver.js",
setupFilesAfterEnv: ["<rootDir>/scripts/setupTest.js"],
globalSetup: "<rootDir>/scripts/globalSetupTest.js",
Expand Down
61 changes: 61 additions & 0 deletions package-lock.json

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

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"test:coverage": "npm run test:only -- --coverage",
"test:watch": "npm run test:coverage --watch",
"test": "npm run test:coverage",
"test:e2e": "npx playwright test",

Choose a reason for hiding this comment

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

Suggested change
"test:e2e": "npx playwright test",
"test:e2e": "playwright test",

"pretest": "npm run lint",
"prepare": "husky && npm run build",
"release": "standard-version"
Expand Down Expand Up @@ -86,6 +87,7 @@
"@babel/runtime": "^7.22.5",
"@commitlint/cli": "^19.0.3",
"@commitlint/config-conventional": "^19.0.3",
"@playwright/test": "^1.44.0",
"@types/compression": "^1.7.2",
"@types/default-gateway": "^3.0.1",
"@types/node": "^20.11.16",
Expand All @@ -110,6 +112,7 @@
"husky": "^9.0.10",
"jest": "^29.5.0",
"jest-environment-jsdom": "^29.5.0",
"jest-mock": "^29.7.0",
"klona": "^2.0.4",
"less": "^4.1.1",
"less-loader": "^12.1.0",
Expand Down
28 changes: 28 additions & 0 deletions playwright.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";

module.exports = {

Choose a reason for hiding this comment

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

Ideally you use defineConfig + '// @ts-check'

testIgnore: "**/*.ignore.*",
testDir: "./test/e2e",
outputDir: ".test/spec/output",
snapshotPathTemplate:
".test/spec/snaps/{projectName}/{testFilePath}/{arg}{ext}",
fullyParallel: false,

Choose a reason for hiding this comment

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

Ideally you enable fullyParallel - didn't it work with having it enabled? Might be a potential follow-up.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, it didn't work at first since we need to set ports, we planed to benefit from it later on.

forbidOnly: process.env.CI !== "true",
retries: process.env.CI ? 2 : 0,
snitin315 marked this conversation as resolved.
Show resolved Hide resolved
workers: 1,
reporter: process.env.CI ? "github" : "list",
use: {
trace: "on-first-retry",
},
projects: [
{
name: "chromium",
use: {
browserName: "chromium",
launchOptions: {

Choose a reason for hiding this comment

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

Since you set ignoreHTTPSErrors in line 26, you can remove the launchOptions lock.

args: ["--ignore-certificate-errors"],
},
},
},
],
};
Loading
Loading