Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

test: move remaining files from old test/ directory (#6081)

Dmitry Gozman5afe282fbbb2
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 0bc7afe568..a3c09982a7 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -40,7 +40,7 @@ jobs:
# Wrap `npm run` in a subshell to redirect STDERR to file.
# Enable core dumps in the subshell.
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash -c "ulimit -c unlimited && npm run test -- ${{ matrix.browser }} --reporter=dot,json"
- - run: node test/checkCoverage.js ${{ matrix.browser }}
+ - run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always() && github.repository == 'microsoft/playwright' && (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release-'))
- uses: actions/upload-artifact@v1
diff --git a/.gitignore b/.gitignore
index 5be73dc582..22f016a50f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,5 @@
/node_modules/
/test-results/
-/test/coverage-report
/tests/coverage-report
.local-browsers/
/.dev_profile*
@@ -9,13 +8,11 @@
*.pyc
.vscode
yarn.lock
-/node6
/src/generated/*
lib/
-jest-report.json
drivers/
.android-sdk/
.gradle/
nohup.out
api.json
-.trace
\ No newline at end of file
+.trace
diff --git a/src/utils/stackTrace.ts b/src/utils/stackTrace.ts
index 7fe6d1c4f2..385812dd61 100644
--- a/src/utils/stackTrace.ts
+++ b/src/utils/stackTrace.ts
@@ -58,7 +58,7 @@ export function captureStackTrace(): { stack: string, frames: StackFrame[] } {
// for tests.
if (isUnderTest() && fileName.includes(path.join('playwright', 'src')))
continue;
- if (isUnderTest() && fileName.includes(path.join('playwright', 'test', 'coverage.js')))
+ if (isUnderTest() && fileName.includes(path.join('playwright', 'tests', 'config', 'coverage.js')))
continue;
frames.push({
file: fileName,
diff --git a/test/tsconfig.json b/test/tsconfig.json
deleted file mode 100644
index c83918cd80..0000000000
--- a/test/tsconfig.json
+++ /dev/null
@@ -1,13 +0,0 @@
-{
- "compilerOptions": {
- "allowJs": true,
- "checkJs": false,
- "noEmit": true,
- "moduleResolution": "node",
- "target": "ESNext",
- "strictNullChecks": false,
- "strictBindCallApply": true,
- "allowSyntheticDefaultImports": true,
- },
- "include": ["**/*.spec.js", "**/*.ts"]
- }
\ No newline at end of file
diff --git a/test/assets/background-color.html b/tests/assets/background-color.html
similarity index 100%
rename from test/assets/background-color.html
rename to tests/assets/background-color.html
diff --git a/test/assets/beforeunload.html b/tests/assets/beforeunload.html
similarity index 100%
rename from test/assets/beforeunload.html
rename to tests/assets/beforeunload.html
diff --git a/test/assets/button-overlay-oopif.html b/tests/assets/button-overlay-oopif.html
similarity index 100%
rename from test/assets/button-overlay-oopif.html
rename to tests/assets/button-overlay-oopif.html
diff --git a/test/assets/cached/one-style.css b/tests/assets/cached/one-style.css
similarity index 100%
rename from test/assets/cached/one-style.css
rename to tests/assets/cached/one-style.css
diff --git a/test/assets/cached/one-style.html b/tests/assets/cached/one-style.html
similarity index 100%
rename from test/assets/cached/one-style.html
rename to tests/assets/cached/one-style.html
diff --git a/test/assets/checkerboard.html b/tests/assets/checkerboard.html
similarity index 100%
rename from test/assets/checkerboard.html
rename to tests/assets/checkerboard.html
diff --git a/test/assets/chromium-linux.zip b/tests/assets/chromium-linux.zip
similarity index 100%
rename from test/assets/chromium-linux.zip
rename to tests/assets/chromium-linux.zip
diff --git a/test/assets/consolelog.html b/tests/assets/consolelog.html
similarity index 100%
rename from test/assets/consolelog.html
rename to tests/assets/consolelog.html
diff --git a/test/assets/csp.html b/tests/assets/csp.html
similarity index 100%
rename from test/assets/csp.html
rename to tests/assets/csp.html
diff --git a/test/assets/csscoverage/Dosis-Regular.ttf b/tests/assets/csscoverage/Dosis-Regular.ttf
similarity index 100%
rename from test/assets/csscoverage/Dosis-Regular.ttf
rename to tests/assets/csscoverage/Dosis-Regular.ttf
diff --git a/test/assets/csscoverage/OFL.txt b/tests/assets/csscoverage/OFL.txt
similarity index 100%
rename from test/assets/csscoverage/OFL.txt
rename to tests/assets/csscoverage/OFL.txt
diff --git a/test/assets/csscoverage/involved.html b/tests/assets/csscoverage/involved.html
similarity index 100%
rename from test/assets/csscoverage/involved.html
rename to tests/assets/csscoverage/involved.html
diff --git a/test/assets/csscoverage/media.html b/tests/assets/csscoverage/media.html
similarity index 100%
rename from test/assets/csscoverage/media.html
rename to tests/assets/csscoverage/media.html
diff --git a/test/assets/csscoverage/multiple.html b/tests/assets/csscoverage/multiple.html
similarity index 100%
rename from test/assets/csscoverage/multiple.html
rename to tests/assets/csscoverage/multiple.html
diff --git a/test/assets/csscoverage/simple.html b/tests/assets/csscoverage/simple.html
similarity index 100%
rename from test/assets/csscoverage/simple.html
rename to tests/assets/csscoverage/simple.html
diff --git a/test/assets/csscoverage/sourceurl.html b/tests/assets/csscoverage/sourceurl.html
similarity index 100%
rename from test/assets/csscoverage/sourceurl.html
rename to tests/assets/csscoverage/sourceurl.html
diff --git a/test/assets/csscoverage/stylesheet1.css b/tests/assets/csscoverage/stylesheet1.css
similarity index 100%
rename from test/assets/csscoverage/stylesheet1.css
rename to tests/assets/csscoverage/stylesheet1.css
diff --git a/test/assets/csscoverage/stylesheet2.css b/tests/assets/csscoverage/stylesheet2.css
similarity index 100%
rename from test/assets/csscoverage/stylesheet2.css
rename to tests/assets/csscoverage/stylesheet2.css
diff --git a/test/assets/csscoverage/unused.html b/tests/assets/csscoverage/unused.html
similarity index 100%
rename from test/assets/csscoverage/unused.html
rename to tests/assets/csscoverage/unused.html
diff --git a/test/assets/deep-shadow.html b/tests/assets/deep-shadow.html
similarity index 100%
rename from test/assets/deep-shadow.html
rename to tests/assets/deep-shadow.html
diff --git a/test/assets/detect-touch.html b/tests/assets/detect-touch.html
similarity index 100%
rename from test/assets/detect-touch.html
rename to tests/assets/detect-touch.html
diff --git a/test/assets/digits/0.png b/tests/assets/digits/0.png
similarity index 100%
rename from test/assets/digits/0.png
rename to tests/assets/digits/0.png
diff --git a/test/assets/digits/1.png b/tests/assets/digits/1.png
similarity index 100%
rename from test/assets/digits/1.png
rename to tests/assets/digits/1.png
diff --git a/test/assets/digits/2.png b/tests/assets/digits/2.png
similarity index 100%
rename from test/assets/digits/2.png
rename to tests/assets/digits/2.png
diff --git a/test/assets/digits/3.png b/tests/assets/digits/3.png
similarity index 100%
rename from test/assets/digits/3.png
rename to tests/assets/digits/3.png
diff --git a/test/assets/digits/4.png b/tests/assets/digits/4.png
similarity index 100%
rename from test/assets/digits/4.png
rename to tests/assets/digits/4.png
diff --git a/test/assets/digits/5.png b/tests/assets/digits/5.png
similarity index 100%
rename from test/assets/digits/5.png
rename to tests/assets/digits/5.png
diff --git a/test/assets/digits/6.png b/tests/assets/digits/6.png
similarity index 100%
rename from test/assets/digits/6.png
rename to tests/assets/digits/6.png
diff --git a/test/assets/digits/7.png b/tests/assets/digits/7.png
similarity index 100%
rename from test/assets/digits/7.png
rename to tests/assets/digits/7.png
diff --git a/test/assets/digits/8.png b/tests/assets/digits/8.png
similarity index 100%
rename from test/assets/digits/8.png
rename to tests/assets/digits/8.png
diff --git a/test/assets/digits/9.png b/tests/assets/digits/9.png
similarity index 100%
rename from test/assets/digits/9.png
rename to tests/assets/digits/9.png
diff --git a/test/assets/dom.html b/tests/assets/dom.html
similarity index 100%
rename from test/assets/dom.html
rename to tests/assets/dom.html
diff --git a/test/assets/download-blob.html b/tests/assets/download-blob.html
similarity index 100%
rename from test/assets/download-blob.html
rename to tests/assets/download-blob.html
diff --git a/test/assets/drag-n-drop.html b/tests/assets/drag-n-drop.html
similarity index 100%
rename from test/assets/drag-n-drop.html
rename to tests/assets/drag-n-drop.html
diff --git a/test/assets/dummy_bad_browser_executable.js b/tests/assets/dummy_bad_browser_executable.js
similarity index 100%
rename from test/assets/dummy_bad_browser_executable.js
rename to tests/assets/dummy_bad_browser_executable.js
diff --git a/test/assets/dynamic-oopif.html b/tests/assets/dynamic-oopif.html
similarity index 100%
rename from test/assets/dynamic-oopif.html
rename to tests/assets/dynamic-oopif.html
diff --git a/test/assets/empty.html b/tests/assets/empty.html
similarity index 100%
rename from test/assets/empty.html
rename to tests/assets/empty.html
diff --git a/test/assets/error.html b/tests/assets/error.html
similarity index 100%
rename from test/assets/error.html
rename to tests/assets/error.html
diff --git a/test/assets/es6/.eslintrc b/tests/assets/es6/.eslintrc
similarity index 100%
rename from test/assets/es6/.eslintrc
rename to tests/assets/es6/.eslintrc
diff --git a/test/assets/es6/es6import.js b/tests/assets/es6/es6import.js
similarity index 100%
rename from test/assets/es6/es6import.js
rename to tests/assets/es6/es6import.js
diff --git a/test/assets/es6/es6module.js b/tests/assets/es6/es6module.js
similarity index 100%
rename from test/assets/es6/es6module.js
rename to tests/assets/es6/es6module.js
diff --git a/test/assets/es6/es6pathimport.js b/tests/assets/es6/es6pathimport.js
similarity index 100%
rename from test/assets/es6/es6pathimport.js
rename to tests/assets/es6/es6pathimport.js
diff --git a/test/assets/file-to-upload-2.txt b/tests/assets/file-to-upload-2.txt
similarity index 100%
rename from test/assets/file-to-upload-2.txt
rename to tests/assets/file-to-upload-2.txt
diff --git a/test/assets/file-to-upload.txt b/tests/assets/file-to-upload.txt
similarity index 100%
rename from test/assets/file-to-upload.txt
rename to tests/assets/file-to-upload.txt
diff --git a/test/assets/formatted-number.html b/tests/assets/formatted-number.html
similarity index 100%
rename from test/assets/formatted-number.html
rename to tests/assets/formatted-number.html
diff --git a/test/assets/frames/child-redirect.html b/tests/assets/frames/child-redirect.html
similarity index 100%
rename from test/assets/frames/child-redirect.html
rename to tests/assets/frames/child-redirect.html
diff --git a/test/assets/frames/frame.html b/tests/assets/frames/frame.html
similarity index 100%
rename from test/assets/frames/frame.html
rename to tests/assets/frames/frame.html
diff --git a/test/assets/frames/frameset.html b/tests/assets/frames/frameset.html
similarity index 100%
rename from test/assets/frames/frameset.html
rename to tests/assets/frames/frameset.html
diff --git a/test/assets/frames/lazy-frame.html b/tests/assets/frames/lazy-frame.html
similarity index 100%
rename from test/assets/frames/lazy-frame.html
rename to tests/assets/frames/lazy-frame.html
diff --git a/test/assets/frames/nested-frames.html b/tests/assets/frames/nested-frames.html
similarity index 100%
rename from test/assets/frames/nested-frames.html
rename to tests/assets/frames/nested-frames.html
diff --git a/test/assets/frames/one-frame.html b/tests/assets/frames/one-frame.html
similarity index 100%
rename from test/assets/frames/one-frame.html
rename to tests/assets/frames/one-frame.html
diff --git a/test/assets/frames/redirect-my-parent.html b/tests/assets/frames/redirect-my-parent.html
similarity index 100%
rename from test/assets/frames/redirect-my-parent.html
rename to tests/assets/frames/redirect-my-parent.html
diff --git a/test/assets/frames/script.js b/tests/assets/frames/script.js
similarity index 100%
rename from test/assets/frames/script.js
rename to tests/assets/frames/script.js
diff --git a/test/assets/frames/style.css b/tests/assets/frames/style.css
similarity index 100%
rename from test/assets/frames/style.css
rename to tests/assets/frames/style.css
diff --git a/test/assets/frames/two-frames.html b/tests/assets/frames/two-frames.html
similarity index 100%
rename from test/assets/frames/two-frames.html
rename to tests/assets/frames/two-frames.html
diff --git a/test/assets/geolocation.html b/tests/assets/geolocation.html
similarity index 100%
rename from test/assets/geolocation.html
rename to tests/assets/geolocation.html
diff --git a/test/assets/global-var.html b/tests/assets/global-var.html
similarity index 100%
rename from test/assets/global-var.html
rename to tests/assets/global-var.html
diff --git a/test/assets/grid-iframe-in-shadow.html b/tests/assets/grid-iframe-in-shadow.html
similarity index 100%
rename from test/assets/grid-iframe-in-shadow.html
rename to tests/assets/grid-iframe-in-shadow.html
diff --git a/test/assets/grid.html b/tests/assets/grid.html
similarity index 100%
rename from test/assets/grid.html
rename to tests/assets/grid.html
diff --git a/test/assets/har.html b/tests/assets/har.html
similarity index 100%
rename from test/assets/har.html
rename to tests/assets/har.html
diff --git a/test/assets/highdpi.html b/tests/assets/highdpi.html
similarity index 100%
rename from test/assets/highdpi.html
rename to tests/assets/highdpi.html
diff --git a/test/assets/historyapi.html b/tests/assets/historyapi.html
similarity index 100%
rename from test/assets/historyapi.html
rename to tests/assets/historyapi.html
diff --git a/test/assets/injectedfile.js b/tests/assets/injectedfile.js
similarity index 100%
rename from test/assets/injectedfile.js
rename to tests/assets/injectedfile.js
diff --git a/test/assets/injectedstyle.css b/tests/assets/injectedstyle.css
similarity index 100%
rename from test/assets/injectedstyle.css
rename to tests/assets/injectedstyle.css
diff --git a/test/assets/input/animating-button.html b/tests/assets/input/animating-button.html
similarity index 100%
rename from test/assets/input/animating-button.html
rename to tests/assets/input/animating-button.html
diff --git a/test/assets/input/button.html b/tests/assets/input/button.html
similarity index 100%
rename from test/assets/input/button.html
rename to tests/assets/input/button.html
diff --git a/test/assets/input/checkbox.html b/tests/assets/input/checkbox.html
similarity index 100%
rename from test/assets/input/checkbox.html
rename to tests/assets/input/checkbox.html
diff --git a/test/assets/input/fileupload.html b/tests/assets/input/fileupload.html
similarity index 100%
rename from test/assets/input/fileupload.html
rename to tests/assets/input/fileupload.html
diff --git a/test/assets/input/keyboard.html b/tests/assets/input/keyboard.html
similarity index 100%
rename from test/assets/input/keyboard.html
rename to tests/assets/input/keyboard.html
diff --git a/test/assets/input/mouse-helper.js b/tests/assets/input/mouse-helper.js
similarity index 100%
rename from test/assets/input/mouse-helper.js
rename to tests/assets/input/mouse-helper.js
diff --git a/test/assets/input/rotatedButton.html b/tests/assets/input/rotatedButton.html
similarity index 100%
rename from test/assets/input/rotatedButton.html
rename to tests/assets/input/rotatedButton.html
diff --git a/test/assets/input/scrollable.html b/tests/assets/input/scrollable.html
similarity index 100%
rename from test/assets/input/scrollable.html
rename to tests/assets/input/scrollable.html
diff --git a/test/assets/input/scrollable2.html b/tests/assets/input/scrollable2.html
similarity index 100%
rename from test/assets/input/scrollable2.html
rename to tests/assets/input/scrollable2.html
diff --git a/test/assets/input/select.html b/tests/assets/input/select.html
similarity index 100%
rename from test/assets/input/select.html
rename to tests/assets/input/select.html
diff --git a/test/assets/input/textarea.html b/tests/assets/input/textarea.html
similarity index 100%
rename from test/assets/input/textarea.html
rename to tests/assets/input/textarea.html
diff --git a/test/assets/input/touches.html b/tests/assets/input/touches.html
similarity index 100%
rename from test/assets/input/touches.html
rename to tests/assets/input/touches.html
diff --git a/test/assets/jscoverage/eval.html b/tests/assets/jscoverage/eval.html
similarity index 100%
rename from test/assets/jscoverage/eval.html
rename to tests/assets/jscoverage/eval.html
diff --git a/test/assets/jscoverage/involved.html b/tests/assets/jscoverage/involved.html
similarity index 100%
rename from test/assets/jscoverage/involved.html
rename to tests/assets/jscoverage/involved.html
diff --git a/test/assets/jscoverage/multiple.html b/tests/assets/jscoverage/multiple.html
similarity index 100%
rename from test/assets/jscoverage/multiple.html
rename to tests/assets/jscoverage/multiple.html
diff --git a/test/assets/jscoverage/ranges.html b/tests/assets/jscoverage/ranges.html
similarity index 100%
rename from test/assets/jscoverage/ranges.html
rename to tests/assets/jscoverage/ranges.html
diff --git a/test/assets/jscoverage/script1.js b/tests/assets/jscoverage/script1.js
similarity index 100%
rename from test/assets/jscoverage/script1.js
rename to tests/assets/jscoverage/script1.js
diff --git a/test/assets/jscoverage/script2.js b/tests/assets/jscoverage/script2.js
similarity index 100%
rename from test/assets/jscoverage/script2.js
rename to tests/assets/jscoverage/script2.js
diff --git a/test/assets/jscoverage/simple.html b/tests/assets/jscoverage/simple.html
similarity index 100%
rename from test/assets/jscoverage/simple.html
rename to tests/assets/jscoverage/simple.html
diff --git a/test/assets/jscoverage/sourceurl.html b/tests/assets/jscoverage/sourceurl.html
similarity index 100%
rename from test/assets/jscoverage/sourceurl.html
rename to tests/assets/jscoverage/sourceurl.html
diff --git a/test/assets/jscoverage/unused.html b/tests/assets/jscoverage/unused.html
similarity index 100%
rename from test/assets/jscoverage/unused.html
rename to tests/assets/jscoverage/unused.html
diff --git a/test/assets/media-query-prefers-color-scheme.svg b/tests/assets/media-query-prefers-color-scheme.svg
similarity index 100%
rename from test/assets/media-query-prefers-color-scheme.svg
rename to tests/assets/media-query-prefers-color-scheme.svg
diff --git a/test/assets/mobile.html b/tests/assets/mobile.html
similarity index 100%
rename from test/assets/mobile.html
rename to tests/assets/mobile.html
diff --git a/test/assets/modernizr.js b/tests/assets/modernizr.js
similarity index 100%
rename from test/assets/modernizr.js
rename to tests/assets/modernizr.js
diff --git a/test/assets/movie.mp4 b/tests/assets/movie.mp4
similarity index 100%
rename from test/assets/movie.mp4
rename to tests/assets/movie.mp4
diff --git a/test/assets/movie.ogv b/tests/assets/movie.ogv
similarity index 100%
rename from test/assets/movie.ogv
rename to tests/assets/movie.ogv
diff --git a/test/assets/networkidle-frame.html b/tests/assets/networkidle-frame.html
similarity index 100%
rename from test/assets/networkidle-frame.html
rename to tests/assets/networkidle-frame.html
diff --git a/test/assets/networkidle.html b/tests/assets/networkidle.html
similarity index 100%
rename from test/assets/networkidle.html
rename to tests/assets/networkidle.html
diff --git a/test/assets/networkidle.js b/tests/assets/networkidle.js
similarity index 100%
rename from test/assets/networkidle.js
rename to tests/assets/networkidle.js
diff --git a/test/assets/offscreenbuttons.html b/tests/assets/offscreenbuttons.html
similarity index 100%
rename from test/assets/offscreenbuttons.html
rename to tests/assets/offscreenbuttons.html
diff --git a/test/assets/one-style.css b/tests/assets/one-style.css
similarity index 100%
rename from test/assets/one-style.css
rename to tests/assets/one-style.css
diff --git a/test/assets/one-style.html b/tests/assets/one-style.html
similarity index 100%
rename from test/assets/one-style.html
rename to tests/assets/one-style.html
diff --git a/test/assets/overflow-large.html b/tests/assets/overflow-large.html
similarity index 100%
rename from test/assets/overflow-large.html
rename to tests/assets/overflow-large.html
diff --git a/test/assets/overflow.html b/tests/assets/overflow.html
similarity index 100%
rename from test/assets/overflow.html
rename to tests/assets/overflow.html
diff --git a/test/assets/player.html b/tests/assets/player.html
similarity index 100%
rename from test/assets/player.html
rename to tests/assets/player.html
diff --git a/test/assets/playground.html b/tests/assets/playground.html
similarity index 100%
rename from test/assets/playground.html
rename to tests/assets/playground.html
diff --git a/test/assets/popup/popup.html b/tests/assets/popup/popup.html
similarity index 100%
rename from test/assets/popup/popup.html
rename to tests/assets/popup/popup.html
diff --git a/test/assets/popup/window-open.html b/tests/assets/popup/window-open.html
similarity index 100%
rename from test/assets/popup/window-open.html
rename to tests/assets/popup/window-open.html
diff --git a/test/assets/pptr.png b/tests/assets/pptr.png
similarity index 100%
rename from test/assets/pptr.png
rename to tests/assets/pptr.png
diff --git a/test/assets/react.html b/tests/assets/react.html
similarity index 100%
rename from test/assets/react.html
rename to tests/assets/react.html
diff --git a/test/assets/react/[email protected] b/tests/assets/react/[email protected]
similarity index 100%
rename from test/assets/react/[email protected]
rename to tests/assets/react/[email protected]
diff --git a/test/assets/react/[email protected] b/tests/assets/react/[email protected]
similarity index 100%
rename from test/assets/react/[email protected]
rename to tests/assets/react/[email protected]
diff --git a/test/assets/redirectloop1.html b/tests/assets/redirectloop1.html
similarity index 100%
rename from test/assets/redirectloop1.html
rename to tests/assets/redirectloop1.html
diff --git a/test/assets/redirectloop2.html b/tests/assets/redirectloop2.html
similarity index 100%
rename from test/assets/redirectloop2.html
rename to tests/assets/redirectloop2.html
diff --git a/test/assets/resetcss.html b/tests/assets/resetcss.html
similarity index 100%
rename from test/assets/resetcss.html
rename to tests/assets/resetcss.html
diff --git a/test/assets/rotate-z.html b/tests/assets/rotate-z.html
similarity index 100%
rename from test/assets/rotate-z.html
rename to tests/assets/rotate-z.html
diff --git a/test/assets/screenshots/canvas.html b/tests/assets/screenshots/canvas.html
similarity index 100%
rename from test/assets/screenshots/canvas.html
rename to tests/assets/screenshots/canvas.html
diff --git a/test/assets/screenshots/controls.html b/tests/assets/screenshots/controls.html
similarity index 100%
rename from test/assets/screenshots/controls.html
rename to tests/assets/screenshots/controls.html
diff --git a/test/assets/screenshots/translateZ.html b/tests/assets/screenshots/translateZ.html
similarity index 100%
rename from test/assets/screenshots/translateZ.html
rename to tests/assets/screenshots/translateZ.html
diff --git a/test/assets/screenshots/webgl.html b/tests/assets/screenshots/webgl.html
similarity index 100%
rename from test/assets/screenshots/webgl.html
rename to tests/assets/screenshots/webgl.html
diff --git a/test/assets/sectionselectorengine.js b/tests/assets/sectionselectorengine.js
similarity index 100%
rename from test/assets/sectionselectorengine.js
rename to tests/assets/sectionselectorengine.js
diff --git a/test/assets/self-request.html b/tests/assets/self-request.html
similarity index 100%
rename from test/assets/self-request.html
rename to tests/assets/self-request.html
diff --git a/test/assets/serviceworkers/empty/sw.html b/tests/assets/serviceworkers/empty/sw.html
similarity index 100%
rename from test/assets/serviceworkers/empty/sw.html
rename to tests/assets/serviceworkers/empty/sw.html
diff --git a/test/assets/serviceworkers/empty/sw.js b/tests/assets/serviceworkers/empty/sw.js
similarity index 100%
rename from test/assets/serviceworkers/empty/sw.js
rename to tests/assets/serviceworkers/empty/sw.js
diff --git a/test/assets/serviceworkers/fetch/style.css b/tests/assets/serviceworkers/fetch/style.css
similarity index 100%
rename from test/assets/serviceworkers/fetch/style.css
rename to tests/assets/serviceworkers/fetch/style.css
diff --git a/test/assets/serviceworkers/fetch/sw.html b/tests/assets/serviceworkers/fetch/sw.html
similarity index 100%
rename from test/assets/serviceworkers/fetch/sw.html
rename to tests/assets/serviceworkers/fetch/sw.html
diff --git a/test/assets/serviceworkers/fetch/sw.js b/tests/assets/serviceworkers/fetch/sw.js
similarity index 100%
rename from test/assets/serviceworkers/fetch/sw.js
rename to tests/assets/serviceworkers/fetch/sw.js
diff --git a/test/assets/serviceworkers/fetchdummy/sw.html b/tests/assets/serviceworkers/fetchdummy/sw.html
similarity index 100%
rename from test/assets/serviceworkers/fetchdummy/sw.html
rename to tests/assets/serviceworkers/fetchdummy/sw.html
diff --git a/test/assets/serviceworkers/fetchdummy/sw.js b/tests/assets/serviceworkers/fetchdummy/sw.js
similarity index 100%
rename from test/assets/serviceworkers/fetchdummy/sw.js
rename to tests/assets/serviceworkers/fetchdummy/sw.js
diff --git a/test/assets/shadow-dom-link.html b/tests/assets/shadow-dom-link.html
similarity index 100%
rename from test/assets/shadow-dom-link.html
rename to tests/assets/shadow-dom-link.html
diff --git a/test/assets/shadow.html b/tests/assets/shadow.html
similarity index 100%
rename from test/assets/shadow.html
rename to tests/assets/shadow.html
diff --git a/test/assets/simple-extension/content-script.js b/tests/assets/simple-extension/content-script.js
similarity index 100%
rename from test/assets/simple-extension/content-script.js
rename to tests/assets/simple-extension/content-script.js
diff --git a/test/assets/simple-extension/index.js b/tests/assets/simple-extension/index.js
similarity index 100%
rename from test/assets/simple-extension/index.js
rename to tests/assets/simple-extension/index.js
diff --git a/test/assets/simple-extension/manifest.json b/tests/assets/simple-extension/manifest.json
similarity index 100%
rename from test/assets/simple-extension/manifest.json
rename to tests/assets/simple-extension/manifest.json
diff --git a/test/assets/simple.json b/tests/assets/simple.json
similarity index 100%
rename from test/assets/simple.json
rename to tests/assets/simple.json
diff --git a/test/assets/tamperable.html b/tests/assets/tamperable.html
similarity index 100%
rename from test/assets/tamperable.html
rename to tests/assets/tamperable.html
diff --git a/test/assets/title.html b/tests/assets/title.html
similarity index 100%
rename from test/assets/title.html
rename to tests/assets/title.html
diff --git a/test/assets/video.html b/tests/assets/video.html
similarity index 100%
rename from test/assets/video.html
rename to tests/assets/video.html
diff --git a/test/assets/video_mp4.html b/tests/assets/video_mp4.html
similarity index 100%
rename from test/assets/video_mp4.html
rename to tests/assets/video_mp4.html
diff --git a/test/assets/wasm/table2.html b/tests/assets/wasm/table2.html
similarity index 100%
rename from test/assets/wasm/table2.html
rename to tests/assets/wasm/table2.html
diff --git a/test/assets/wasm/table2.wasm b/tests/assets/wasm/table2.wasm
similarity index 100%
rename from test/assets/wasm/table2.wasm
rename to tests/assets/wasm/table2.wasm
diff --git a/test/assets/worker/import-me.js b/tests/assets/worker/import-me.js
similarity index 100%
rename from test/assets/worker/import-me.js
rename to tests/assets/worker/import-me.js
diff --git a/test/assets/worker/worker-http-import.html b/tests/assets/worker/worker-http-import.html
similarity index 100%
rename from test/assets/worker/worker-http-import.html
rename to tests/assets/worker/worker-http-import.html
diff --git a/test/assets/worker/worker-http-import.js b/tests/assets/worker/worker-http-import.js
similarity index 100%
rename from test/assets/worker/worker-http-import.js
rename to tests/assets/worker/worker-http-import.js
diff --git a/test/assets/worker/worker.html b/tests/assets/worker/worker.html
similarity index 100%
rename from test/assets/worker/worker.html
rename to tests/assets/worker/worker.html
diff --git a/test/assets/worker/worker.js b/tests/assets/worker/worker.js
similarity index 100%
rename from test/assets/worker/worker.js
rename to tests/assets/worker/worker.js
diff --git a/test/assets/wrappedlink.html b/tests/assets/wrappedlink.html
similarity index 100%
rename from test/assets/wrappedlink.html
rename to tests/assets/wrappedlink.html
diff --git a/tests/browsercontext-add-init-script.spec.ts b/tests/browsercontext-add-init-script.spec.ts
index 0649bcaf74..86c5705ddc 100644
--- a/tests/browsercontext-add-init-script.spec.ts
+++ b/tests/browsercontext-add-init-script.spec.ts
@@ -16,7 +16,6 @@
*/
import { contextTest as it, expect } from './config/browserTest';
-import path from 'path';
it('should work with browser context scripts', async ({ context, server }) => {
await context.addInitScript(() => window['temp'] = 123);
@@ -53,8 +52,8 @@ it('should work without navigation in popup', async ({ context }) => {
expect(await popup.evaluate(() => window['temp'])).toBe(123);
});
-it('should work with browser context scripts with a path', async ({ context, server }) => {
- await context.addInitScript({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
+it('should work with browser context scripts with a path', async ({ context, server, asset }) => {
+ await context.addInitScript({ path: asset('injectedfile.js') });
const page = await context.newPage();
await page.goto(server.PREFIX + '/tamperable.html');
expect(await page.evaluate(() => window['result'])).toBe(123);
diff --git a/tests/browsercontext-basic.spec.ts b/tests/browsercontext-basic.spec.ts
index fa2675c12d..20551af0d2 100644
--- a/tests/browsercontext-basic.spec.ts
+++ b/tests/browsercontext-basic.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/browserTest';
-import { verifyViewport } from '../test/utils';
+import { verifyViewport } from './config/utils';
it('should create new context', async function({browser}) {
expect(browser.contexts().length).toBe(0);
diff --git a/tests/browsercontext-csp.spec.ts b/tests/browsercontext-csp.spec.ts
index 229731887a..6f7b474c8f 100644
--- a/tests/browsercontext-csp.spec.ts
+++ b/tests/browsercontext-csp.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should bypass CSP meta tag', async ({browser, server}) => {
// Make sure CSP prohibits addScriptTag.
diff --git a/tests/browsercontext-user-agent.spec.ts b/tests/browsercontext-user-agent.spec.ts
index d25186c246..141199edab 100644
--- a/tests/browsercontext-user-agent.spec.ts
+++ b/tests/browsercontext-user-agent.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should work', async ({browser, server}) => {
{
diff --git a/tests/browsercontext-viewport.spec.ts b/tests/browsercontext-viewport.spec.ts
index f9922aa47b..82fcf3a7ff 100644
--- a/tests/browsercontext-viewport.spec.ts
+++ b/tests/browsercontext-viewport.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
-import { verifyViewport } from '../test/utils';
+import { verifyViewport } from './config/utils';
it.beforeEach(async () => {
it.skip(!!process.env.PW_ANDROID_TESTS);
diff --git a/tests/browsertype-launch.spec.ts b/tests/browsertype-launch.spec.ts
index 2b4f5c7a88..0357722f2a 100644
--- a/tests/browsertype-launch.spec.ts
+++ b/tests/browsertype-launch.spec.ts
@@ -15,7 +15,6 @@
* limitations under the License.
*/
-import path from 'path';
import { test as it, slowTest, expect } from './config/playwrightTest';
it('should reject all promises when browser is closed', async ({browserType, browserOptions}) => {
@@ -64,8 +63,8 @@ it('should throw if page argument is passed', async ({browserType, browserOption
expect(waitError.message).toContain('can not specify page');
});
-it('should reject if launched browser fails immediately', async ({browserType, browserOptions}) => {
- const options = Object.assign({}, browserOptions, {executablePath: path.join(__dirname, '..', 'test', 'assets', 'dummy_bad_browser_executable.js')});
+it('should reject if launched browser fails immediately', async ({browserType, browserOptions, asset}) => {
+ const options = Object.assign({}, browserOptions, {executablePath: asset('dummy_bad_browser_executable.js')});
let waitError = null;
await browserType.launch(options).catch(e => waitError = e);
expect(waitError.message).toContain('== logs ==');
diff --git a/tests/chromium/launcher.spec.ts b/tests/chromium/launcher.spec.ts
index 6b8aacf162..c1a05902ce 100644
--- a/tests/chromium/launcher.spec.ts
+++ b/tests/chromium/launcher.spec.ts
@@ -15,7 +15,6 @@
*/
import { test as it, expect } from '../config/playwrightTest';
-import path from 'path';
it.beforeEach(async ({ browserName }) => {
it.skip(browserName !== 'chromium');
@@ -57,9 +56,9 @@ it('should open devtools when "devtools: true" option is given', async ({browser
await browser.close();
});
-it('should return background pages', async ({browserType, browserOptions, createUserDataDir}) => {
+it('should return background pages', async ({browserType, browserOptions, createUserDataDir, asset}) => {
const userDataDir = await createUserDataDir();
- const extensionPath = path.join(__dirname, '..', '..', 'test', 'assets', 'simple-extension');
+ const extensionPath = asset('simple-extension');
const extensionOptions = {...browserOptions,
headless: false,
args: [
@@ -78,9 +77,9 @@ it('should return background pages', async ({browserType, browserOptions, create
await context.close();
});
-it('should return background pages when recording video', async ({browserType, browserOptions, createUserDataDir}, testInfo) => {
+it('should return background pages when recording video', async ({browserType, browserOptions, createUserDataDir, asset}, testInfo) => {
const userDataDir = await createUserDataDir();
- const extensionPath = path.join(__dirname, '..', '..', 'test', 'assets', 'simple-extension');
+ const extensionPath = asset('simple-extension');
const extensionOptions = {...browserOptions,
headless: false,
args: [
diff --git a/tests/cli/cli-codegen-2.spec.ts b/tests/cli/cli-codegen-2.spec.ts
index 5e4d06487c..a42b4c3c4c 100644
--- a/tests/cli/cli-codegen-2.spec.ts
+++ b/tests/cli/cli-codegen-2.spec.ts
@@ -117,7 +117,7 @@ await page.CloseAsync();`);
expect(errors.length).toBe(0);
});
- test('should upload a single file', async ({ page, openRecorder, browserName }) => {
+ test('should upload a single file', async ({ page, openRecorder, browserName, asset }) => {
test.fixme(browserName === 'firefox', 'Hangs');
const recorder = await openRecorder();
@@ -128,7 +128,7 @@ await page.CloseAsync();`);
`);
await page.focus('input[type=file]');
- await page.setInputFiles('input[type=file]', 'test/assets/file-to-upload.txt');
+ await page.setInputFiles('input[type=file]', asset('file-to-upload.txt'));
await page.click('input[type=file]');
const sources = await recorder.waitForOutput('<javascript>', 'setInputFiles');
@@ -155,7 +155,7 @@ await page.SetInputFilesAsync(\"input[type=\\\"file\\\"]\", \"file-to-upload.txt
});
- test('should upload multiple files', async ({ page, openRecorder, browserName }) => {
+ test('should upload multiple files', async ({ page, openRecorder, browserName, asset }) => {
test.fixme(browserName === 'firefox', 'Hangs');
const recorder = await openRecorder();
@@ -166,7 +166,7 @@ await page.SetInputFilesAsync(\"input[type=\\\"file\\\"]\", \"file-to-upload.txt
`);
await page.focus('input[type=file]');
- await page.setInputFiles('input[type=file]', ['test/assets/file-to-upload.txt', 'test/assets/file-to-upload-2.txt']);
+ await page.setInputFiles('input[type=file]', [asset('file-to-upload.txt'), asset('file-to-upload-2.txt')]);
await page.click('input[type=file]');
const sources = await recorder.waitForOutput('<javascript>', 'setInputFiles');
@@ -192,7 +192,7 @@ await page.SetInputFilesAsync(\"input[type=\\\"file\\\"]\", \"file-to-upload.txt
await page.SetInputFilesAsync(\"input[type=\\\"file\\\"]\", new[] { \"file-to-upload.txt\", \"file-to-upload-2.txt\" });`);
});
- test('should clear files', async ({ page, openRecorder, browserName }) => {
+ test('should clear files', async ({ page, openRecorder, browserName, asset }) => {
test.fixme(browserName === 'firefox', 'Hangs');
const recorder = await openRecorder();
@@ -202,7 +202,7 @@ await page.SetInputFilesAsync(\"input[type=\\\"file\\\"]\", new[] { \"file-to-up
</form>
`);
await page.focus('input[type=file]');
- await page.setInputFiles('input[type=file]', 'test/assets/file-to-upload.txt');
+ await page.setInputFiles('input[type=file]', asset('file-to-upload.txt'));
await page.setInputFiles('input[type=file]', []);
await page.click('input[type=file]');
diff --git a/tests/cli/cli-codegen-csharp.spec.ts b/tests/cli/cli-codegen-csharp.spec.ts
index 5bfbbd7a87..2abef1df75 100644
--- a/tests/cli/cli-codegen-csharp.spec.ts
+++ b/tests/cli/cli-codegen-csharp.spec.ts
@@ -18,7 +18,7 @@ import path from 'path';
import fs from 'fs';
import { test, expect } from '../config/cliTest';
-const emptyHTML = new URL('file://' + path.join(__dirname, '..', '..', 'test', 'assets', 'empty.html')).toString();
+const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
const launchOptions = (channel: string) => {
return channel ? `headless: false,\n channel: "${channel}"` : 'headless: false';
};
diff --git a/tests/cli/cli-codegen-java.spec.ts b/tests/cli/cli-codegen-java.spec.ts
index 94279f6b76..3fe1ba23a7 100644
--- a/tests/cli/cli-codegen-java.spec.ts
+++ b/tests/cli/cli-codegen-java.spec.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import { test, expect } from '../config/cliTest';
-const emptyHTML = new URL('file://' + path.join(__dirname, '..', '..', 'test', 'assets', 'empty.html')).toString();
+const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
const launchOptions = (channel: string) => {
return channel ? `.setHeadless(false)\n .setChannel("${channel}")` : '.setHeadless(false)';
};
diff --git a/tests/cli/cli-codegen-javascript.spec.ts b/tests/cli/cli-codegen-javascript.spec.ts
index 90694af473..947f184074 100644
--- a/tests/cli/cli-codegen-javascript.spec.ts
+++ b/tests/cli/cli-codegen-javascript.spec.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import { test, expect } from '../config/cliTest';
-const emptyHTML = new URL('file://' + path.join(__dirname, '..', '..', 'test', 'assets', 'empty.html')).toString();
+const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
const launchOptions = (channel: string) => {
return channel ? `headless: false,\n channel: '${channel}'` : 'headless: false';
diff --git a/tests/cli/cli-codegen-python-async.spec.ts b/tests/cli/cli-codegen-python-async.spec.ts
index 2a9965dc0d..0722026cc3 100644
--- a/tests/cli/cli-codegen-python-async.spec.ts
+++ b/tests/cli/cli-codegen-python-async.spec.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import { test, expect } from '../config/cliTest';
-const emptyHTML = new URL('file://' + path.join(__dirname, '..', '..', 'test', 'assets', 'empty.html')).toString();
+const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
const launchOptions = (channel: string) => {
return channel ? `headless=False, channel="${channel}"` : 'headless=False';
};
diff --git a/tests/cli/cli-codegen-python.spec.ts b/tests/cli/cli-codegen-python.spec.ts
index 3b3470ae6b..7dd6fde89a 100644
--- a/tests/cli/cli-codegen-python.spec.ts
+++ b/tests/cli/cli-codegen-python.spec.ts
@@ -18,7 +18,7 @@ import fs from 'fs';
import path from 'path';
import { test, expect } from '../config/cliTest';
-const emptyHTML = new URL('file://' + path.join(__dirname, '..', '..', 'test', 'assets', 'empty.html')).toString();
+const emptyHTML = new URL('file://' + path.join(__dirname, '..', 'assets', 'empty.html')).toString();
const launchOptions = (channel: string) => {
return channel ? `headless=False, channel="${channel}"` : 'headless=False';
};
diff --git a/tests/config/browserEnv.ts b/tests/config/browserEnv.ts
index 8813cfbc06..a620b0b70f 100644
--- a/tests/config/browserEnv.ts
+++ b/tests/config/browserEnv.ts
@@ -16,7 +16,7 @@
import type { Env, WorkerInfo, TestInfo } from 'folio';
import type { Browser, BrowserContext, BrowserContextOptions, BrowserType, LaunchOptions } from '../../index';
-import { installCoverageHooks } from '../../test/coverage';
+import { installCoverageHooks } from './coverage';
import { start } from '../../lib/outofprocess';
import { PlaywrightClient } from '../../lib/remote/playwrightClient';
import { removeFolders } from '../../lib/utils/utils';
@@ -202,7 +202,7 @@ export class PlaywrightEnv implements Env<PlaywrightTestArgs> {
await this._mode.teardown();
const { coverage, uninstall } = this._coverage!;
uninstall();
- const coveragePath = path.join(__dirname, '..', '..', 'test', 'coverage-report', workerInfo.workerIndex + '.json');
+ const coveragePath = path.join(__dirname, '..', 'coverage-report', workerInfo.workerIndex + '.json');
const coverageJSON = Array.from(coverage.keys()).filter(key => coverage.get(key));
await fs.promises.mkdir(path.dirname(coveragePath), { recursive: true });
await fs.promises.writeFile(coveragePath, JSON.stringify(coverageJSON, undefined, 2), 'utf8');
diff --git a/test/checkCoverage.js b/tests/config/checkCoverage.js
similarity index 97%
rename from test/checkCoverage.js
rename to tests/config/checkCoverage.js
index 658c118a43..1a8b8e7019 100644
--- a/test/checkCoverage.js
+++ b/tests/config/checkCoverage.js
@@ -54,7 +54,7 @@ if (browserName === 'webkit')
// Android coverage is abysmal.
api = new Set(Array.from(api).filter(name => !name.toLowerCase().startsWith('android')));
-const coverageDir = path.join(__dirname, 'coverage-report');
+const coverageDir = path.join(__dirname, '..', 'coverage-report');
const coveredMethods = new Set();
for (const file of getCoverageFiles(coverageDir)) {
diff --git a/test/coverage.js b/tests/config/coverage.js
similarity index 96%
rename from test/coverage.js
rename to tests/config/coverage.js
index 1d0c2a6e43..24a0bb463c 100644
--- a/test/coverage.js
+++ b/tests/config/coverage.js
@@ -60,8 +60,8 @@ function traceAPICoverage(apiCoverage, api, events) {
* @param {string} browserName
*/
function apiForBrowser(browserName) {
- const events = require('../lib/client/events').Events;
- const api = require('../lib/client/api');
+ const events = require('../../lib/client/events').Events;
+ const api = require('../../lib/client/api');
const otherBrowsers = ['chromium', 'webkit', 'firefox'].filter(name => name.toLowerCase() !== browserName.toLowerCase());
const filteredKeys = Object.keys(api).filter(apiName => {
if (apiName.toLowerCase().startsWith('electron'))
diff --git a/test/run_static_server.js b/tests/config/run_static_server.js
similarity index 100%
rename from test/run_static_server.js
rename to tests/config/run_static_server.js
diff --git a/tests/config/serverEnv.ts b/tests/config/serverEnv.ts
index 15c8f453c9..cdda097d15 100644
--- a/tests/config/serverEnv.ts
+++ b/tests/config/serverEnv.ts
@@ -27,8 +27,8 @@ export class ServerEnv implements Env<ServerTestArgs> {
private _socksPort: number;
async beforeAll(workerInfo: WorkerInfo) {
- const assetsPath = path.join(__dirname, '..', '..', 'test', 'assets');
- const cachedPath = path.join(__dirname, '..', '..', 'test', 'assets', 'cached');
+ const assetsPath = path.join(__dirname, '..', 'assets');
+ const cachedPath = path.join(__dirname, '..', 'assets', 'cached');
const port = 8907 + workerInfo.workerIndex * 3;
this._server = await TestServer.create(assetsPath, port);
@@ -63,7 +63,7 @@ export class ServerEnv implements Env<ServerTestArgs> {
this._server.reset();
this._httpsServer.reset();
return {
- asset: (p: string) => path.join(__dirname, '..', '..', 'test', 'assets', p),
+ asset: (p: string) => path.join(__dirname, '..', 'assets', ...p.split('/')),
server: this._server,
httpsServer: this._httpsServer,
socksPort: this._socksPort,
diff --git a/test/utils.ts b/tests/config/utils.ts
similarity index 97%
rename from test/utils.ts
rename to tests/config/utils.ts
index 45fc1003dc..4c2d0f863a 100644
--- a/test/utils.ts
+++ b/tests/config/utils.ts
@@ -15,7 +15,7 @@
*/
import { expect } from 'folio';
-import type { Frame, Page } from '../index';
+import type { Frame, Page } from '../../index';
export async function attachFrame(page: Page, frameId: string, url: string): Promise<Frame> {
const handle = await page.evaluateHandle(async ({ frameId, url }) => {
diff --git a/tests/defaultbrowsercontext-1.spec.ts b/tests/defaultbrowsercontext-1.spec.ts
index 774162a384..5d80a91424 100644
--- a/tests/defaultbrowsercontext-1.spec.ts
+++ b/tests/defaultbrowsercontext-1.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/playwrightTest';
-import { verifyViewport } from '../test/utils';
+import { verifyViewport } from './config/utils';
import fs from 'fs';
it('context.cookies() should work', async ({server, launchPersistent}) => {
diff --git a/tests/elementhandle-content-frame.spec.ts b/tests/elementhandle-content-frame.spec.ts
index 9ca6225a3d..22a6812c0b 100644
--- a/tests/elementhandle-content-frame.spec.ts
+++ b/tests/elementhandle-content-frame.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/tests/elementhandle-owner-frame.spec.ts b/tests/elementhandle-owner-frame.spec.ts
index e5ce7f674b..9efe9484da 100644
--- a/tests/elementhandle-owner-frame.spec.ts
+++ b/tests/elementhandle-owner-frame.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should work', async ({ page, server }) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/tests/elementhandle-screenshot.spec.ts b/tests/elementhandle-screenshot.spec.ts
index 9429421461..4396607196 100644
--- a/tests/elementhandle-screenshot.spec.ts
+++ b/tests/elementhandle-screenshot.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
-import { verifyViewport } from '../test/utils';
+import { verifyViewport } from './config/utils';
import {PNG} from 'pngjs';
import path from 'path';
import fs from 'fs';
diff --git a/tests/emulation-focus.spec.ts b/tests/emulation-focus.spec.ts
index ed47bc8d0d..bec91a68e5 100644
--- a/tests/emulation-focus.spec.ts
+++ b/tests/emulation-focus.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should think that it is focused by default', async ({page}) => {
expect(await page.evaluate('document.hasFocus()')).toBe(true);
diff --git a/tests/favicon.spec.ts b/tests/favicon.spec.ts
index 25c2b89697..f968c21b34 100644
--- a/tests/favicon.spec.ts
+++ b/tests/favicon.spec.ts
@@ -15,10 +15,9 @@
* limitations under the License.
*/
-import path from 'path';
import { test as it } from './config/browserTest';
-it('should load svg favicon with prefer-color-scheme', async ({contextFactory, server, browserName, browserChannel, headful}) => {
+it('should load svg favicon with prefer-color-scheme', async ({contextFactory, server, browserName, browserChannel, headful, asset}) => {
it.skip(!headful && browserName !== 'firefox', 'headless browsers, except firefox, do not request favicons');
it.skip(headful && browserName === 'webkit' && !browserChannel, 'playwright headful webkit does not have a favicon feature');
@@ -29,7 +28,7 @@ it('should load svg favicon with prefer-color-scheme', async ({contextFactory, s
// `d` parameter to make iterating on this test more predictable and isolated.
const favicon = `/favicon.svg?d=${Date.now()}`;
server.setRoute(favicon, (req, res) => {
- server.serveFile(req, res, path.join(__dirname, 'assets', 'media-query-prefers-color-scheme.svg'));
+ server.serveFile(req, res, asset('media-query-prefers-color-scheme.svg'));
});
server.setRoute('/page.html', (_, res) => {
diff --git a/tests/frame-evaluate.spec.ts b/tests/frame-evaluate.spec.ts
index aa8f1706c4..5060287061 100644
--- a/tests/frame-evaluate.spec.ts
+++ b/tests/frame-evaluate.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame, detachFrame } from '../test/utils';
+import { attachFrame, detachFrame } from './config/utils';
import type { Frame } from '../src/client/frame';
it('should have different execution contexts', async ({ page, server }) => {
diff --git a/tests/frame-frame-element.spec.ts b/tests/frame-frame-element.spec.ts
index 692183c86e..b471510e06 100644
--- a/tests/frame-frame-element.spec.ts
+++ b/tests/frame-frame-element.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/tests/frame-goto.spec.ts b/tests/frame-goto.spec.ts
index b2ab907b08..6a71c9b9b2 100644
--- a/tests/frame-goto.spec.ts
+++ b/tests/frame-goto.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should navigate subframes', async ({page, server}) => {
await page.goto(server.PREFIX + '/frames/one-frame.html');
diff --git a/tests/frame-hierarchy.spec.ts b/tests/frame-hierarchy.spec.ts
index 11d4dcbedf..00f2d6e596 100644
--- a/tests/frame-hierarchy.spec.ts
+++ b/tests/frame-hierarchy.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame, detachFrame } from '../test/utils';
+import { attachFrame, detachFrame } from './config/utils';
import type { Frame } from '../index';
function dumpFrames(frame: Frame, indentation: string = ''): string[] {
diff --git a/tests/page-add-init-script.spec.ts b/tests/page-add-init-script.spec.ts
index 4aaf68d061..1de68bbee8 100644
--- a/tests/page-add-init-script.spec.ts
+++ b/tests/page-add-init-script.spec.ts
@@ -16,7 +16,6 @@
*/
import { test as it, expect } from './config/pageTest';
-import path from 'path';
it('should evaluate before anything else on the page', async ({ page, server }) => {
await page.addInitScript(function() {
@@ -26,8 +25,8 @@ it('should evaluate before anything else on the page', async ({ page, server })
expect(await page.evaluate(() => window['result'])).toBe(123);
});
-it('should work with a path', async ({ page, server }) => {
- await page.addInitScript({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
+it('should work with a path', async ({ page, server, asset }) => {
+ await page.addInitScript({ path: asset('injectedfile.js') });
await page.goto(server.PREFIX + '/tamperable.html');
expect(await page.evaluate(() => window['result'])).toBe(123);
});
diff --git a/tests/page-add-script-tag.spec.ts b/tests/page-add-script-tag.spec.ts
index ccc23e0a4c..80a571ee93 100644
--- a/tests/page-add-script-tag.spec.ts
+++ b/tests/page-add-script-tag.spec.ts
@@ -42,9 +42,9 @@ it('should work with a url and type=module', async ({page, server}) => {
expect(await page.evaluate(() => window['__es6injected'])).toBe(42);
});
-it('should work with a path and type=module', async ({page, server}) => {
+it('should work with a path and type=module', async ({page, server, asset}) => {
await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, '../test/assets/es6/es6pathimport.js'), type: 'module' });
+ await page.addScriptTag({ path: asset('es6/es6pathimport.js'), type: 'module' });
await page.waitForFunction('window.__es6injected');
expect(await page.evaluate(() => window['__es6injected'])).toBe(42);
});
@@ -67,18 +67,18 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
expect(error).not.toBe(null);
});
-it('should work with a path', async ({page, server}) => {
+it('should work with a path', async ({page, server, asset}) => {
await page.goto(server.EMPTY_PAGE);
- const scriptHandle = await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
+ const scriptHandle = await page.addScriptTag({ path: asset('injectedfile.js') });
expect(scriptHandle.asElement()).not.toBeNull();
expect(await page.evaluate(() => window['__injected'])).toBe(42);
});
-it('should include sourceURL when path is provided', async ({page, server, isWebKit}) => {
+it('should include sourceURL when path is provided', async ({page, server, isWebKit, asset}) => {
it.skip(isWebKit);
await page.goto(server.EMPTY_PAGE);
- await page.addScriptTag({ path: path.join(__dirname, '../test/assets/injectedfile.js') });
+ await page.addScriptTag({ path: asset('injectedfile.js') });
const result = await page.evaluate(() => window['__injectedError'].stack);
expect(result).toContain(path.join('assets', 'injectedfile.js'));
});
diff --git a/tests/page-add-style-tag.spec.ts b/tests/page-add-style-tag.spec.ts
index 6e53a8431c..6b6bdd939a 100644
--- a/tests/page-add-style-tag.spec.ts
+++ b/tests/page-add-style-tag.spec.ts
@@ -47,16 +47,16 @@ it('should throw an error if loading from url fail', async ({page, server}) => {
expect(error).not.toBe(null);
});
-it('should work with a path', async ({page, server}) => {
+it('should work with a path', async ({page, server, asset}) => {
await page.goto(server.EMPTY_PAGE);
- const styleHandle = await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
+ const styleHandle = await page.addStyleTag({ path: asset('injectedstyle.css') });
expect(styleHandle.asElement()).not.toBeNull();
expect(await page.evaluate(`window.getComputedStyle(document.querySelector('body')).getPropertyValue('background-color')`)).toBe('rgb(255, 0, 0)');
});
-it('should include sourceURL when path is provided', async ({page, server}) => {
+it('should include sourceURL when path is provided', async ({page, server, asset}) => {
await page.goto(server.EMPTY_PAGE);
- await page.addStyleTag({ path: path.join(__dirname, '../test/assets/injectedstyle.css') });
+ await page.addStyleTag({ path: asset('injectedstyle.css') });
const styleHandle = await page.$('style');
const styleContent = await page.evaluate(style => style.innerHTML, styleHandle);
expect(styleContent).toContain(path.join('assets', 'injectedstyle.css'));
diff --git a/tests/page-click.spec.ts b/tests/page-click.spec.ts
index 88cee57d51..df3e6a24bd 100644
--- a/tests/page-click.spec.ts
+++ b/tests/page-click.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
async function giveItAChanceToClick(page) {
for (let i = 0; i < 5; i++)
diff --git a/tests/page-drag.spec.ts b/tests/page-drag.spec.ts
index d8393d73e3..d5799ba4b4 100644
--- a/tests/page-drag.spec.ts
+++ b/tests/page-drag.spec.ts
@@ -16,7 +16,7 @@
import type { ElementHandle } from '../index';
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it.describe('Drag and drop', () => {
it.beforeEach(async ({ browserName }) => {
diff --git a/tests/page-emulate-media.spec.ts b/tests/page-emulate-media.spec.ts
index 6d7015f07f..e9e4cc6057 100644
--- a/tests/page-emulate-media.spec.ts
+++ b/tests/page-emulate-media.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it.beforeEach(async () => {
it.skip(!!process.env.PW_ANDROID_TESTS);
diff --git a/tests/page-event-request.spec.ts b/tests/page-event-request.spec.ts
index fbce07e394..1f051fd738 100644
--- a/tests/page-event-request.spec.ts
+++ b/tests/page-event-request.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should fire for navigation requests', async ({page, server}) => {
const requests = [];
diff --git a/tests/page-expose-function.spec.ts b/tests/page-expose-function.spec.ts
index 669b680cfa..e551fcd53a 100644
--- a/tests/page-expose-function.spec.ts
+++ b/tests/page-expose-function.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
import type { ElementHandle } from '../index';
it('exposeBinding should work', async ({page}) => {
diff --git a/tests/page-goto.spec.ts b/tests/page-goto.spec.ts
index 0695e63bef..ae36754bb6 100644
--- a/tests/page-goto.spec.ts
+++ b/tests/page-goto.spec.ts
@@ -15,21 +15,20 @@
* limitations under the License.
*/
-import path from 'path';
import url from 'url';
import { test as it, expect } from './config/pageTest';
import { slowTest } from './config/browserTest';
-import { expectedSSLError } from '../test/utils';
+import { expectedSSLError } from './config/utils';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
expect(page.url()).toBe(server.EMPTY_PAGE);
});
-it('should work with file URL', async ({page}) => {
+it('should work with file URL', async ({page, asset}) => {
it.skip(!!process.env.PW_ANDROID_TESTS, 'No files on Android');
- const fileurl = url.pathToFileURL(path.join(__dirname, '..', 'test', 'assets', 'frames', 'two-frames.html')).href;
+ const fileurl = url.pathToFileURL(asset('frames/two-frames.html')).href;
await page.goto(fileurl);
expect(page.url().toLowerCase()).toBe(fileurl.toLowerCase());
expect(page.frames().length).toBe(3);
diff --git a/tests/page-in-context.spec.ts b/tests/page-in-context.spec.ts
index 5e1109fb50..95961fa006 100644
--- a/tests/page-in-context.spec.ts
+++ b/tests/page-in-context.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should not be visible in context.pages', async ({contextFactory}) => {
const context = await contextFactory();
diff --git a/tests/page-keyboard.spec.ts b/tests/page-keyboard.spec.ts
index 612e314340..61e8cb5931 100644
--- a/tests/page-keyboard.spec.ts
+++ b/tests/page-keyboard.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it.beforeEach(async () => {
it.skip(!!process.env.PW_ANDROID_TESTS);
diff --git a/tests/page-network-request.spec.ts b/tests/page-network-request.spec.ts
index 8a7afdb798..ba31e26874 100644
--- a/tests/page-network-request.spec.ts
+++ b/tests/page-network-request.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
it('should work for main frame navigation request', async ({page, server}) => {
const requests = [];
diff --git a/tests/page-network-response.spec.ts b/tests/page-network-response.spec.ts
index 728e341680..d10fe5d37e 100644
--- a/tests/page-network-response.spec.ts
+++ b/tests/page-network-response.spec.ts
@@ -17,7 +17,6 @@
import { test as it, expect } from './config/pageTest';
import fs from 'fs';
-import path from 'path';
it('should work', async ({page, server}) => {
server.setRoute('/empty.html', (req, res) => {
@@ -95,17 +94,17 @@ it('should return json', async ({page, server}) => {
expect(await response.json()).toEqual({foo: 'bar'});
});
-it('should return body', async ({page, server}) => {
+it('should return body', async ({page, server, asset}) => {
const response = await page.goto(server.PREFIX + '/pptr.png');
- const imageBuffer = fs.readFileSync(path.join(__dirname, '..', 'test', 'assets', 'pptr.png'));
+ const imageBuffer = fs.readFileSync(asset('pptr.png'));
const responseBuffer = await response.body();
expect(responseBuffer.equals(imageBuffer)).toBe(true);
});
-it('should return body with compression', async ({page, server}) => {
+it('should return body with compression', async ({page, server, asset}) => {
server.enableGzip('/pptr.png');
const response = await page.goto(server.PREFIX + '/pptr.png');
- const imageBuffer = fs.readFileSync(path.join(__dirname, '..', 'test', 'assets', 'pptr.png'));
+ const imageBuffer = fs.readFileSync(asset('pptr.png'));
const responseBuffer = await response.body();
expect(responseBuffer.equals(imageBuffer)).toBe(true);
});
diff --git a/tests/page-request-fulfill.spec.ts b/tests/page-request-fulfill.spec.ts
index e6a21e906d..451d274edb 100644
--- a/tests/page-request-fulfill.spec.ts
+++ b/tests/page-request-fulfill.spec.ts
@@ -18,8 +18,6 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
import fs from 'fs';
-import path from 'path';
-
it('should work', async ({page, server}) => {
await page.route('**/*', route => {
@@ -51,12 +49,12 @@ it('should work with status code 422', async ({page, server}) => {
expect(await page.evaluate(() => document.body.textContent)).toBe('Yo, page!');
});
-it('should allow mocking binary responses', async ({page, server, browserName, headful}) => {
+it('should allow mocking binary responses', async ({page, server, browserName, headful, asset}) => {
it.skip(browserName === 'firefox' && headful, 'Firefox headful produces a different image.');
it.skip(!!process.env.PW_ANDROID_TESTS);
await page.route('**/*', route => {
- const imageBuffer = fs.readFileSync(path.join(__dirname, '..', 'test', 'assets', 'pptr.png'));
+ const imageBuffer = fs.readFileSync(asset('pptr.png'));
route.fulfill({
contentType: 'image/png',
body: imageBuffer
@@ -93,10 +91,10 @@ it('should allow mocking svg with charset', async ({page, server, browserName, h
expect(await img.screenshot()).toMatchSnapshot('mock-svg.png');
});
-it('should work with file path', async ({page, server}) => {
+it('should work with file path', async ({page, server, asset}) => {
it.skip(!!process.env.PW_ANDROID_TESTS);
- await page.route('**/*', route => route.fulfill({ contentType: 'shouldBeIgnored', path: path.join(__dirname, '..', 'test', 'assets', 'pptr.png') }));
+ await page.route('**/*', route => route.fulfill({ contentType: 'shouldBeIgnored', path: asset('pptr.png') }));
await page.evaluate(PREFIX => {
const img = document.createElement('img');
img.src = PREFIX + '/does-not-exist.png';
diff --git a/tests/page-screenshot.spec.ts b/tests/page-screenshot.spec.ts
index 78e1730d7a..d8ee6112eb 100644
--- a/tests/page-screenshot.spec.ts
+++ b/tests/page-screenshot.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest, slowTest as slowBrowserTest } from './config/browserTest';
-import { verifyViewport } from '../test/utils';
+import { verifyViewport } from './config/utils';
import path from 'path';
import fs from 'fs';
import { PNG } from 'pngjs';
diff --git a/tests/page-set-input-files.spec.ts b/tests/page-set-input-files.spec.ts
index 9665f392fc..055f901855 100644
--- a/tests/page-set-input-files.spec.ts
+++ b/tests/page-set-input-files.spec.ts
@@ -21,11 +21,9 @@ import path from 'path';
import fs from 'fs';
import formidable from 'formidable';
-const FILE_TO_UPLOAD = path.join(__dirname, '../test/assets/file-to-upload.txt');
-
-it('should upload the file', async ({page, server}) => {
+it('should upload the file', async ({page, server, asset}) => {
await page.goto(server.PREFIX + '/input/fileupload.html');
- const filePath = path.relative(process.cwd(), FILE_TO_UPLOAD);
+ const filePath = path.relative(process.cwd(), asset('file-to-upload.txt'));
const input = await page.$('input');
await input.setInputFiles(filePath);
expect(await page.evaluate(e => e.files[0].name, input)).toBe('file-to-upload.txt');
@@ -37,9 +35,9 @@ it('should upload the file', async ({page, server}) => {
}, input)).toBe('contents of the file');
});
-it('should work', async ({page}) => {
+it('should work', async ({page, asset}) => {
await page.setContent(`<input type=file>`);
- await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
+ await page.setInputFiles('input', asset('file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -103,9 +101,9 @@ it('should work when file input is attached to DOM', async ({page, server}) => {
expect(chooser).toBeTruthy();
});
-it('should work when file input is not attached to DOM', async ({page, server}) => {
+it('should work when file input is not attached to DOM', async ({page, asset}) => {
const [,content] = await Promise.all([
- page.waitForEvent('filechooser').then(chooser => chooser.setFiles(FILE_TO_UPLOAD)),
+ page.waitForEvent('filechooser').then(chooser => chooser.setFiles(asset('file-to-upload.txt'))),
page.evaluate(async () => {
const el = document.createElement('input');
el.type = 'file';
@@ -164,11 +162,11 @@ it('should not throw when frame is detached immediately', async ({page, server})
await page.waitForFunction(() => (window as any).__done);
});
-it('should work with CSP', async ({page, server}) => {
+it('should work with CSP', async ({page, server, asset}) => {
server.setCSP('/empty.html', 'default-src "none"');
await page.goto(server.EMPTY_PAGE);
await page.setContent(`<input type=file>`);
- await page.setInputFiles('input', path.join(__dirname, '../test/assets/file-to-upload.txt'));
+ await page.setInputFiles('input', asset('file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
@@ -215,7 +213,7 @@ it('should return the same file chooser when there are many watchdogs simultaneo
expect(fileChooser1 === fileChooser2).toBe(true);
});
-it('should accept single file', async ({page, server}) => {
+it('should accept single file', async ({page, asset}) => {
await page.setContent(`<input type=file oninput='javascript:console.timeStamp()'>`);
const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'),
@@ -223,12 +221,12 @@ it('should accept single file', async ({page, server}) => {
]);
expect(fileChooser.page()).toBe(page);
expect(fileChooser.element()).toBeTruthy();
- await fileChooser.setFiles(FILE_TO_UPLOAD);
+ await fileChooser.setFiles(asset('file-to-upload.txt'));
expect(await page.$eval('input', input => input.files.length)).toBe(1);
expect(await page.$eval('input', input => input.files[0].name)).toBe('file-to-upload.txt');
});
-it('should detect mime type', async ({page, server}) => {
+it('should detect mime type', async ({page, server, asset}) => {
it.fixme(!!process.env.PW_ANDROID_TESTS);
let files;
@@ -246,8 +244,8 @@ it('should detect mime type', async ({page, server}) => {
<input type="file" name="file2">
<input type="submit" value="Submit">
</form>`);
- await (await page.$('input[name=file1]')).setInputFiles(path.join(__dirname, '../test/assets/file-to-upload.txt'));
- await (await page.$('input[name=file2]')).setInputFiles(path.join(__dirname, '../test/assets/pptr.png'));
+ await (await page.$('input[name=file1]')).setInputFiles(asset('file-to-upload.txt'));
+ await (await page.$('input[name=file2]')).setInputFiles(asset('pptr.png'));
await Promise.all([
page.click('input[type=submit]'),
server.waitForRequest('/upload'),
@@ -256,17 +254,17 @@ it('should detect mime type', async ({page, server}) => {
expect(file1.name).toBe('file-to-upload.txt');
expect(file1.type).toBe('text/plain');
expect(fs.readFileSync(file1.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '../test/assets/file-to-upload.txt')).toString());
+ fs.readFileSync(asset('file-to-upload.txt')).toString());
expect(file2.name).toBe('pptr.png');
expect(file2.type).toBe('image/png');
expect(fs.readFileSync(file2.path).toString()).toBe(
- fs.readFileSync(path.join(__dirname, '../test/assets/pptr.png')).toString());
+ fs.readFileSync(asset('pptr.png')).toString());
});
-it('should be able to read selected file', async ({page, server}) => {
+it('should be able to read selected file', async ({page, asset}) => {
await page.setContent(`<input type=file>`);
const [, content] = await Promise.all([
- page.waitForEvent('filechooser').then(fileChooser => fileChooser.setFiles(FILE_TO_UPLOAD)),
+ page.waitForEvent('filechooser').then(fileChooser => fileChooser.setFiles(asset('file-to-upload.txt'))),
page.$eval('input', async picker => {
picker.click();
await new Promise(x => picker.oninput = x);
@@ -279,10 +277,10 @@ it('should be able to read selected file', async ({page, server}) => {
expect(content).toBe('contents of the file');
});
-it('should be able to reset selected files with empty file list', async ({page, server}) => {
+it('should be able to reset selected files with empty file list', async ({page, asset}) => {
await page.setContent(`<input type=file>`);
const [, fileLength1] = await Promise.all([
- page.waitForEvent('filechooser').then(fileChooser => fileChooser.setFiles(FILE_TO_UPLOAD)),
+ page.waitForEvent('filechooser').then(fileChooser => fileChooser.setFiles(asset('file-to-upload.txt'))),
page.$eval('input', async picker => {
picker.click();
await new Promise(x => picker.oninput = x);
@@ -301,7 +299,7 @@ it('should be able to reset selected files with empty file list', async ({page,
expect(fileLength2).toBe(0);
});
-it('should not accept multiple files for single-file input', async ({page, server}) => {
+it('should not accept multiple files for single-file input', async ({page, asset}) => {
await page.setContent(`<input type=file>`);
const [fileChooser] = await Promise.all([
page.waitForEvent('filechooser'),
@@ -309,13 +307,13 @@ it('should not accept multiple files for single-file input', async ({page, serve
]);
let error = null;
await fileChooser.setFiles([
- path.join(__dirname, '../test/assets/file-to-upload.txt'),
- path.join(__dirname, '../test/assets/pptr.png')
+ asset('file-to-upload.txt'),
+ asset('pptr.png')
]).catch(e => error = e);
expect(error).not.toBe(null);
});
-it('should emit input and change events', async ({page, server}) => {
+it('should emit input and change events', async ({page, asset}) => {
const events = [];
await page.exposeFunction('eventHandled', e => events.push(e));
await page.setContent(`
@@ -324,7 +322,7 @@ it('should emit input and change events', async ({page, server}) => {
input.addEventListener('input', e => eventHandled({ type: e.type }));
input.addEventListener('change', e => eventHandled({ type: e.type }));
</script>`);
- await (await page.$('input')).setInputFiles(FILE_TO_UPLOAD);
+ await (await page.$('input')).setInputFiles(asset('file-to-upload.txt'));
expect(events.length).toBe(2);
expect(events[0].type).toBe('input');
expect(events[1].type).toBe('change');
diff --git a/tests/page-wait-for-navigation.spec.ts b/tests/page-wait-for-navigation.spec.ts
index f8124992e0..c74495bdf9 100644
--- a/tests/page-wait-for-navigation.spec.ts
+++ b/tests/page-wait-for-navigation.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import type { Frame } from '../index';
-import { expectedSSLError } from '../test/utils';
+import { expectedSSLError } from './config/utils';
it('should work', async ({page, server}) => {
await page.goto(server.EMPTY_PAGE);
diff --git a/tests/page-wait-for-selector-1.spec.ts b/tests/page-wait-for-selector-1.spec.ts
index ab3b08b157..d50ac4233e 100644
--- a/tests/page-wait-for-selector-1.spec.ts
+++ b/tests/page-wait-for-selector-1.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame, detachFrame } from '../test/utils';
+import { attachFrame, detachFrame } from './config/utils';
async function giveItTimeToLog(frame) {
await frame.evaluate(() => new Promise(f => requestAnimationFrame(() => requestAnimationFrame(f))));
diff --git a/tests/page-wait-for-selector-2.spec.ts b/tests/page-wait-for-selector-2.spec.ts
index fe1f74c60a..3449718edb 100644
--- a/tests/page-wait-for-selector-2.spec.ts
+++ b/tests/page-wait-for-selector-2.spec.ts
@@ -16,7 +16,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame, detachFrame } from '../test/utils';
+import { attachFrame, detachFrame } from './config/utils';
const addElement = tag => document.body.appendChild(document.createElement(tag));
diff --git a/tests/selectors-register.spec.ts b/tests/selectors-register.spec.ts
index 1549295b5c..53df13d9b7 100644
--- a/tests/selectors-register.spec.ts
+++ b/tests/selectors-register.spec.ts
@@ -16,7 +16,6 @@
*/
import { test as it, expect } from './config/browserTest';
-import path from 'path';
it('should work', async ({playwright, browser}) => {
const createTagSelector = () => ({
@@ -52,9 +51,9 @@ it('should work', async ({playwright, browser}) => {
await context.close();
});
-it('should work with path', async ({playwright, browser}) => {
+it('should work with path', async ({playwright, browser, asset}) => {
const page = await browser.newPage();
- await playwright.selectors.register('foo', { path: path.join(__dirname, '../test/assets/sectionselectorengine.js') });
+ await playwright.selectors.register('foo', { path: asset('sectionselectorengine.js') });
await page.setContent('<section></section>');
expect(await page.$eval('foo=whatever', e => e.nodeName)).toBe('SECTION');
});
diff --git a/tests/slowmo.spec.ts b/tests/slowmo.spec.ts
index bc4e07602c..0ca0662918 100644
--- a/tests/slowmo.spec.ts
+++ b/tests/slowmo.spec.ts
@@ -15,7 +15,7 @@
*/
import { test as it, expect } from './config/pageTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
async function checkSlowMo(toImpl, page, task) {
let didSlowMo = false;
diff --git a/tests/workers.spec.ts b/tests/workers.spec.ts
index 516fddf793..adbd22ed22 100644
--- a/tests/workers.spec.ts
+++ b/tests/workers.spec.ts
@@ -17,7 +17,7 @@
import { test as it, expect } from './config/pageTest';
import { test as browserTest } from './config/browserTest';
-import { attachFrame } from '../test/utils';
+import { attachFrame } from './config/utils';
import type { ConsoleMessage } from '../index';
it('Page.workers', async function({page, server}) {