Browse Source

chore: migrate to monorepo (#9421)

pull/9428/head
Joel Einbinder 2 weeks ago
committed by GitHub
parent
commit
c89d5a50dd
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      .eslintignore
  2. 3
      .github/workflows/infra.yml
  3. 2
      .github/workflows/package_create_playwright.yml
  4. 3
      .github/workflows/publish_canary_driver.yml
  5. 3
      .github/workflows/publish_canary_npm.yml
  6. 6
      .github/workflows/publish_release.yml
  7. 3
      .github/workflows/roll_browser_into_playwright.yml
  8. 1
      .github/workflows/tests_docker.yml
  9. 6
      .github/workflows/tests_fyi.yml
  10. 6
      .github/workflows/tests_primary.yml
  11. 80
      .github/workflows/tests_secondary.yml
  12. 5
      .gitignore
  13. 2
      babel.config.json
  14. 15
      install-from-github.js
  15. 0
      installation-tests/.gitignore
  16. 0
      installation-tests/README.md
  17. 2
      installation-tests/driver-client.js
  18. 0
      installation-tests/electron-app.js
  19. 2
      installation-tests/esm-playwright-chromium.mjs
  20. 2
      installation-tests/esm-playwright-firefox.mjs
  21. 2
      installation-tests/esm-playwright-test.mjs
  22. 2
      installation-tests/esm-playwright-webkit.mjs
  23. 2
      installation-tests/esm-playwright.mjs
  24. 0
      installation-tests/esm.mjs
  25. 0
      installation-tests/inspector-custom-executable.js
  26. 71
      installation-tests/installation-tests.sh
  27. 0
      installation-tests/playwright-test-types.ts
  28. 0
      installation-tests/read-json-report.js
  29. 0
      installation-tests/sample.spec.js
  30. 0
      installation-tests/sanity-electron.js
  31. 4
      installation-tests/sanity.js
  32. 0
      installation-tests/screencast.js
  33. 0
      installation-tests/validate-dependencies-skip-executable-path.js
  34. 0
      installation-tests/validate-dependencies.js
  35. 7405
      package-lock.json
  36. 69
      package.json
  37. 48
      packages/README.md
  38. 229
      packages/build_package.js
  39. 3955
      packages/create-playwright/package-lock.json
  40. 1
      packages/create-playwright/package.json
  41. 2
      packages/create-playwright/tests/integration.spec.ts
  42. 1
      packages/installation-tests/.gitignore
  43. 2
      packages/playwright-chromium/README.md
  44. 2
      packages/playwright-chromium/index.d.ts
  45. 2
      packages/playwright-chromium/index.js
  46. 18
      packages/playwright-chromium/index.mjs
  47. 5
      packages/playwright-chromium/install.js
  48. 27
      packages/playwright-chromium/package.json
  49. 6
      packages/playwright-core/.npmignore
  50. 0
      packages/playwright-core/bin/PrintDeps.exe
  51. 0
      packages/playwright-core/bin/README.md
  52. 0
      packages/playwright-core/bin/android-driver-target.apk
  53. 0
      packages/playwright-core/bin/android-driver.apk
  54. 0
      packages/playwright-core/bin/install_media_pack.ps1
  55. 0
      packages/playwright-core/bin/reinstall_chrome_beta_linux.sh
  56. 0
      packages/playwright-core/bin/reinstall_chrome_beta_mac.sh
  57. 0
      packages/playwright-core/bin/reinstall_chrome_beta_win.ps1
  58. 0
      packages/playwright-core/bin/reinstall_chrome_stable_linux.sh
  59. 0
      packages/playwright-core/bin/reinstall_chrome_stable_mac.sh
  60. 0
      packages/playwright-core/bin/reinstall_chrome_stable_win.ps1
  61. 0
      packages/playwright-core/bin/reinstall_msedge_beta_linux.sh
  62. 0
      packages/playwright-core/bin/reinstall_msedge_beta_mac.sh
  63. 0
      packages/playwright-core/bin/reinstall_msedge_beta_win.ps1
  64. 0
      packages/playwright-core/bin/reinstall_msedge_dev_linux.sh
  65. 0
      packages/playwright-core/bin/reinstall_msedge_dev_mac.sh
  66. 0
      packages/playwright-core/bin/reinstall_msedge_dev_win.ps1
  67. 0
      packages/playwright-core/bin/reinstall_msedge_stable_mac.sh
  68. 0
      packages/playwright-core/bin/reinstall_msedge_stable_win.ps1
  69. 0
      packages/playwright-core/browsers.json
  70. 17
      packages/playwright-core/cli.js
  71. 0
      packages/playwright-core/index.d.ts
  72. 0
      packages/playwright-core/index.js
  73. 0
      packages/playwright-core/index.mjs
  74. 46
      packages/playwright-core/package.json
  75. 2
      packages/playwright-core/src/.eslintrc.js
  76. 0
      packages/playwright-core/src/browserServerImpl.ts
  77. 11
      packages/playwright-core/src/cli/cli.ts
  78. 0
      packages/playwright-core/src/cli/driver.ts
  79. 0
      packages/playwright-core/src/client/accessibility.ts
  80. 0
      packages/playwright-core/src/client/android.ts
  81. 0
      packages/playwright-core/src/client/api.ts
  82. 0
      packages/playwright-core/src/client/artifact.ts
  83. 0
      packages/playwright-core/src/client/browser.ts
  84. 0
      packages/playwright-core/src/client/browserContext.ts
  85. 0
      packages/playwright-core/src/client/browserType.ts
  86. 0
      packages/playwright-core/src/client/cdpSession.ts
  87. 0
      packages/playwright-core/src/client/channelOwner.ts
  88. 0
      packages/playwright-core/src/client/clientHelper.ts
  89. 0
      packages/playwright-core/src/client/connection.ts
  90. 0
      packages/playwright-core/src/client/consoleMessage.ts
  91. 0
      packages/playwright-core/src/client/coverage.ts
  92. 0
      packages/playwright-core/src/client/dialog.ts
  93. 0
      packages/playwright-core/src/client/download.ts
  94. 0
      packages/playwright-core/src/client/electron.ts
  95. 0
      packages/playwright-core/src/client/elementHandle.ts
  96. 0
      packages/playwright-core/src/client/events.ts
  97. 0
      packages/playwright-core/src/client/fetch.ts
  98. 0
      packages/playwright-core/src/client/fileChooser.ts
  99. 0
      packages/playwright-core/src/client/frame.ts
  100. 0
      packages/playwright-core/src/client/input.ts

8
.eslintignore

@ -1,9 +1,9 @@
test/assets/modernizr.js
lib/
/packages/*/lib/
*.js
src/generated/*
src/third_party/
/types/*
/packages/playwright-core/src/generated/*
/packages/playwright-core/src/third_party/
/packages/playwright-core/types/*
/index.d.ts
utils/generate_types/overrides.d.ts
utils/generate_types/test/test.ts

3
.github/workflows/infra.yml

@ -19,9 +19,10 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: npm run lint
- name: Verify clean tree
run: |

2
.github/workflows/package_create_playwright.yml

@ -21,6 +21,8 @@ jobs:
with:
node-version: 14
cache: 'npm'
- run: npm i -g npm@7
- run: npm ci
- run: npm i --no-save @playwright/test
- run: npm run build
- run: npm run test

3
.github/workflows/publish_canary_driver.yml

@ -17,9 +17,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --commit-timestamp
- run: utils/build/build-playwright-driver.sh
- run: utils/build/upload-playwright-driver.sh

3
.github/workflows/publish_canary_npm.yml

@ -19,9 +19,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --today-date
if: contains(github.ref, 'master') && github.event_name != 'workflow_dispatch'
- run: node utils/build/update_canary_version.js --commit-timestamp

6
.github/workflows/publish_release.yml

@ -15,9 +15,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: utils/publish_all_packages.sh --release
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
@ -32,9 +33,10 @@ jobs:
with:
node-version: 12
registry-url: 'https://registry.npmjs.org'
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: utils/build/build-playwright-driver.sh
- run: utils/build/upload-playwright-driver.sh
env:

3
.github/workflows/roll_browser_into_playwright.yml

@ -12,10 +12,11 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 16
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- name: Install dependencies
run: node lib/cli/cli install-deps
run: npx playwright install-deps
- name: Roll to new revision
run: |
./utils/roll_browser.js ${{ github.event.client_payload.browser }} ${{ github.event.client_payload.revision }}

1
.github/workflows/tests_docker.yml

@ -39,6 +39,7 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- name: Build

6
.github/workflows/tests_fyi.yml

@ -24,12 +24,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
env:
PWTEST_VIDEO: 1
@ -53,11 +54,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 14
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- name: Create Android Emulator
run: utils/avd_recreate.sh
- name: Start Android Emulator

6
.github/workflows/tests_primary.yml

@ -32,12 +32,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
- run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -60,11 +61,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install --with-deps
- run: npx playwright install --with-deps
- run: npm run ttest
if: matrix.os != 'ubuntu-latest'
- run: xvfb-run npm run ttest

80
.github/workflows/tests_secondary.yml

@ -33,12 +33,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
- run: node tests/config/checkCoverage.js ${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -62,12 +63,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: npm run test -- --project=${{ matrix.browser }}
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
if: always()
@ -89,12 +91,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: npm run test -- --project=${{ matrix.browser }}
shell: bash
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -121,12 +124,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node_version }}
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
- run: npm run build
- run: node lib/cli/cli install-deps
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash packages/installation-tests/installation-tests.sh
- run: npx playwright install-deps
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- bash installation-tests/installation-tests.sh
headful_linux:
name: "Headful Linux"
@ -140,12 +144,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
if: ${{ always() }}
env:
@ -170,12 +175,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chromium
- run: npx playwright install --with-deps chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_MODE: ${{ matrix.mode }}
@ -199,12 +205,13 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
DEBUG: pw:install
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps ${{ matrix.browser }} chromium
- run: npx playwright install --with-deps ${{ matrix.browser }} chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run test -- --project=${{ matrix.browser }}
env:
PWTEST_TRACE: 1
@ -219,11 +226,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: chrome
@ -243,11 +251,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: npm run ctest
shell: bash
env:
@ -269,11 +278,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome
- run: npx playwright install --with-deps chrome
- run: npm run ctest
env:
PWTEST_CHANNEL: chrome
@ -293,11 +303,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ftest
env:
PWTEST_CHANNEL: firefox-beta
@ -317,11 +328,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: npm run ftest
shell: bash
env:
@ -343,11 +355,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps firefox-beta chromium
- run: npx playwright install --with-deps firefox-beta chromium
- run: npm run ftest
env:
PWTEST_CHANNEL: firefox-beta
@ -367,11 +380,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge
- run: npx playwright install --with-deps msedge
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge
@ -392,11 +406,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge
- run: npx playwright install --with-deps msedge
- run: npm run ctest
shell: bash
env:
@ -415,11 +430,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge-beta
@ -439,11 +455,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: npm run ctest
shell: bash
env:
@ -462,11 +479,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-beta
- run: npx playwright install --with-deps msedge-beta
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: msedge-beta
@ -486,11 +504,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: npm run ctest
env:
PWTEST_CHANNEL: msedge-dev
@ -510,11 +529,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: npm run ctest
shell: bash
env:
@ -533,11 +553,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps msedge-dev
- run: npx playwright install --with-deps msedge-dev
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: msedge-dev
@ -557,11 +578,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run ctest
env:
PWTEST_CHANNEL: chrome-beta
@ -581,11 +603,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: npm run ctest
shell: bash
env:
@ -607,11 +630,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chrome-beta
- run: npx playwright install --with-deps chrome-beta
- run: npm run ctest
env:
PWTEST_CHANNEL: chrome-beta
@ -631,11 +655,12 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
env:
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
- run: npm run build
- run: node lib/cli/cli install --with-deps chromium
- run: npx playwright install --with-deps chromium
- run: xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npm run etest
- run: node tests/config/checkCoverage.js electron
- run: ./utils/upload_flakiness_dashboard.sh ./test-results/report.json
@ -654,8 +679,9 @@ jobs:
- uses: actions/setup-node@v2
with:
node-version: 12
- run: npm i -g npm@7
- run: npm ci
- run: npm run build
- run: node lib/cli/cli install-deps
- run: npx playwright install-deps
- run: node utils/build/update_canary_version.js --today-date
- run: utils/build/build-playwright-driver.sh

5
.gitignore

@ -9,7 +9,7 @@ node_modules/
.vscode
.idea
yarn.lock
/src/generated/*
/packages/playwright-core/src/generated/*
lib/
drivers/
.android-sdk/
@ -20,3 +20,6 @@ nohup.out
allure*
playwright-report
/demo/
/packages/*/LICENSE
/packages/*/NOTICE
/packages/playwright/README.md

2
babel.config.json

@ -13,6 +13,6 @@
],
"ignore": [
"**/*.d.ts",
"src/injected/**/*"
"packages/playwright-core/src/injected/**/*"
]
}

15
install-from-github.js

@ -17,7 +17,7 @@
// This file is only run when someone installs via the github repo
const {execSync} = require('child_process');
const { execSync } = require('child_process');
const path = require('path');
console.log(`Updating test runner...`);
@ -30,18 +30,9 @@ try {
process.exit(1);
}
console.log(`Rebuilding installer...`);
try {
execSync('npm run build-installer', {
stdio: ['inherit', 'inherit', 'inherit'],
});
} catch (e) {
process.exit(1);
}
console.log(`Downloading browsers...`);
const { installDefaultBrowsersForNpmInstall } = require('./lib/utils/registry');
installDefaultBrowsersForNpmInstall().catch(e => {
const { installDefaultBrowsersForNpmInstall } = require('./packages/playwright-core/lib/utils/registry');
installDefaultBrowsersForNpmInstall().catch(e => {
console.error(`Failed to install browsers, caused by\n${e.stack}`);
process.exit(1);
});

0
packages/.gitignore → installation-tests/.gitignore

0
packages/installation-tests/README.md → installation-tests/README.md

2
packages/installation-tests/driver-client.js → installation-tests/driver-client.js

@ -14,7 +14,7 @@
* limitations under the License.
*/
const { start } = require('playwright/lib/outofprocess.js');
const { start } = require('playwright-core/lib/outofprocess');
(async () => {
const playwright = await start();

0
packages/installation-tests/electron-app.js → installation-tests/electron-app.js

2
packages/installation-tests/esm-playwright-chromium.mjs → installation-tests/esm-playwright-chromium.mjs

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-chromium';
import playwright from 'playwright-chromium';
import errorsFile from 'playwright-chromium/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [chromium]);

2
packages/installation-tests/esm-playwright-firefox.mjs → installation-tests/esm-playwright-firefox.mjs

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-firefox';
import playwright from 'playwright-firefox';
import errorsFile from 'playwright-firefox/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [firefox]);

2
packages/installation-tests/esm-playwright-test.mjs → installation-tests/esm-playwright-test.mjs

@ -17,7 +17,7 @@
import { chromium, firefox, webkit, selectors, devices, errors, test, expect } from '@playwright/test';
import * as playwright from '@playwright/test';
import defaultExport from '@playwright/test';
import errorsFile from '@playwright/test/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
if (defaultExport !== test) {

2
packages/installation-tests/esm-playwright-webkit.mjs → installation-tests/esm-playwright-webkit.mjs

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright-webkit';
import playwright from 'playwright-webkit';
import errorsFile from 'playwright-webkit/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [webkit]);

2
packages/installation-tests/esm-playwright.mjs → installation-tests/esm-playwright.mjs

@ -16,7 +16,7 @@
import { chromium, firefox, webkit, selectors, devices, errors } from 'playwright';
import playwright from 'playwright';
import errorsFile from 'playwright/lib/utils/errors.js';
import errorsFile from 'playwright-core/lib/utils/errors';
import testESM from './esm.mjs';
testESM({ chromium, firefox, webkit, selectors, devices, errors, playwright, errorsFile }, [chromium, firefox, webkit]);

0
packages/installation-tests/esm.mjs → installation-tests/esm.mjs

0
packages/installation-tests/inspector-custom-executable.js → installation-tests/inspector-custom-executable.js

71
packages/installation-tests/installation-tests.sh → installation-tests/installation-tests.sh

@ -16,7 +16,7 @@ export PLAYWRIGHT_BROWSERS_PATH=0
# Pack all packages and put them in our output folder.
echo "Building packages..."
PACKAGE_BUILDER="../../../packages/build_package.js"
PACKAGE_BUILDER="../../utils/pack_package.js"
PLAYWRIGHT_CORE_TGZ="$(node ${PACKAGE_BUILDER} playwright-core ./playwright-core.tgz)"
echo "playwright-core built"
PLAYWRIGHT_TGZ="$(node ${PACKAGE_BUILDER} playwright ./playwright.tgz)"
@ -34,7 +34,7 @@ SCRIPTS_PATH="$(pwd -P)/.."
TEST_ROOT="/tmp/playwright-installation-tests"
rm -rf "${TEST_ROOT}"
mkdir -p "${TEST_ROOT}"
NODE_VERSION="$(node --version)"
NODE_VERSION=$(node -e "console.log(process.version.slice(1).split('.')[0])")
function copy_test_scripts {
cp "${SCRIPTS_PATH}/inspector-custom-executable.js" .
@ -74,17 +74,12 @@ function run_tests {
test_playwright_cli_install_should_work
test_playwright_cli_codegen_should_work
test_playwright_driver_should_work
# npm v7 that comes with Node v16 swallows output from install scripts,
# so the following tests won't work.
# See discussion at https://github.com/npm/cli/issues/1651
if [[ "${NODE_VERSION}" != *"v16."* ]]; then
test_skip_browser_download
test_skip_browser_download_inspect_with_custom_executable
test_playwright_should_work
test_playwright_chromium_should_work
test_playwright_webkit_should_work
test_playwright_firefox_should_work
fi
test_skip_browser_download
test_skip_browser_download_inspect_with_custom_executable
test_playwright_should_work
test_playwright_chromium_should_work
test_playwright_webkit_should_work
test_playwright_firefox_should_work
}
function test_screencast {
@ -92,6 +87,7 @@ function test_screencast {
copy_test_scripts
local BROWSERS="$(pwd -P)/browsers"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_WEBKIT_TGZ}
@ -111,7 +107,7 @@ function test_typescript_types {
copy_test_scripts
# install all packages.
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_WEBKIT_TGZ}
@ -139,6 +135,7 @@ function test_playwright_global_installation {
initialize_test "${FUNCNAME[0]}"
local BROWSERS="$(pwd -P)/browsers"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
if [[ ! -d "${BROWSERS}" ]]; then
echo "Directory for shared browsers was not created!"
@ -156,6 +153,7 @@ function test_playwright_global_installation {
function test_playwright_global_installation_cross_package {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_FIREFOX_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_WEBKIT_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_CHROMIUM_TGZ}
@ -185,6 +183,7 @@ function test_playwright_global_installation_subsequent_installs {
local BROWSERS="$(pwd -P)/browsers"
mkdir install-1 && pushd install-1 && npm init -y
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="${BROWSERS}" npm install ${PLAYWRIGHT_TGZ}
# Note: the `npm install` would not actually crash, the error
# is merely logged to the console. To reproduce the error, we should make
@ -199,7 +198,8 @@ function test_playwright_global_installation_subsequent_installs {
function test_skip_browser_download {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
echo "missing log message that browsers download is skipped"
exit 1
@ -217,7 +217,8 @@ function test_skip_browser_download_inspect_with_custom_executable {
initialize_test "${FUNCNAME[0]}"
copy_test_scripts
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"Skipping browsers download because"* ]]; then
echo "missing log message that browsers download is skipped"
exit 1
@ -242,7 +243,8 @@ function test_skip_browser_download_inspect_with_custom_executable {
function test_playwright_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_TGZ})
if [[ "${OUTPUT}" != *"chromium"* ]]; then
echo "ERROR: should download chromium"
exit 1
@ -259,7 +261,7 @@ function test_playwright_should_work {
echo "Running sanity.js"
node sanity.js playwright
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright.mjs
fi
@ -275,6 +277,7 @@ function test_playwright_should_work {
function test_playwright_should_work_with_relative_home_path {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="" HOME=. npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
echo "Running sanity.js"
@ -289,6 +292,7 @@ function test_playwright_should_work_with_relative_browsers_path {
# Make sure that browsers path is resolved relative to the `npm install` call location.
mkdir foo
cd foo
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_BROWSERS_PATH="../relative" npm install ${PLAYWRIGHT_TGZ}
cd ..
@ -301,7 +305,8 @@ function test_playwright_should_work_with_relative_browsers_path {
function test_playwright_chromium_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_CHROMIUM_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_CHROMIUM_TGZ})
if [[ "${OUTPUT}" != *"chromium"* ]]; then
echo "ERROR: should download chromium"
exit 1
@ -318,7 +323,7 @@ function test_playwright_chromium_should_work {
echo "Running sanity.js"
node sanity.js playwright-chromium
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-chromium.mjs
fi
@ -329,7 +334,8 @@ function test_playwright_chromium_should_work {
function test_playwright_webkit_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_WEBKIT_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_WEBKIT_TGZ})
if [[ "${OUTPUT}" == *"chromium"* ]]; then
echo "ERROR: should not download chromium"
exit 1
@ -346,7 +352,7 @@ function test_playwright_webkit_should_work {
echo "Running sanity.js"
node sanity.js playwright-webkit
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-webkit.mjs
fi
@ -357,7 +363,8 @@ function test_playwright_webkit_should_work {
function test_playwright_firefox_should_work {
initialize_test "${FUNCNAME[0]}"
OUTPUT=$(npm install ${PLAYWRIGHT_FIREFOX_TGZ})
npm install ${PLAYWRIGHT_CORE_TGZ}
OUTPUT=$(npm install --foreground-script ${PLAYWRIGHT_FIREFOX_TGZ})
if [[ "${OUTPUT}" == *"chromium"* ]]; then
echo "ERROR: should not download chromium"
exit 1
@ -374,7 +381,7 @@ function test_playwright_firefox_should_work {
echo "Running sanity.js"
node sanity.js playwright-firefox
if [[ "${NODE_VERSION}" == *"v14."* ]]; then
if [[ ${NODE_VERSION} -ge 14 ]]; then
echo "Running esm.js"
node esm-playwright-firefox.mjs
fi
@ -385,6 +392,7 @@ function test_playwright_firefox_should_work {
function test_playwright_validate_dependencies {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
@ -400,6 +408,7 @@ function test_playwright_validate_dependencies {
function test_playwright_validate_dependencies_skip_executable_path {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
copy_test_scripts
@ -415,6 +424,7 @@ function test_playwright_validate_dependencies_skip_executable_path {
function test_playwright_electron_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install electron@9.0
copy_test_scripts
@ -427,10 +437,11 @@ function test_playwright_electron_should_work {
function test_electron_types {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install electron@9.0
npm install electron@12
npm install -D typescript@3.8
npm install -D @types/node@10.17
npm install -D @types/node@14
echo "import { Page, _electron, ElectronApplication, Electron } from 'playwright';" > "test.ts"
echo "Running tsc"
@ -442,9 +453,10 @@ function test_electron_types {
function test_android_types {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
npm install -D typescript@3.8
npm install -D @types/node@10.17
npm install -D @types/node@14
echo "import { AndroidDevice, _android, AndroidWebView, Page } from 'playwright';" > "test.ts"
echo "Running tsc"
@ -456,6 +468,7 @@ function test_android_types {
function test_playwright_cli_screenshot_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright screenshot"
@ -478,6 +491,7 @@ function test_playwright_cli_screenshot_should_work {
function test_playwright_cli_install_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
local BROWSERS="$(pwd -P)/browsers"
@ -531,6 +545,7 @@ function test_playwright_cli_install_should_work {
function test_playwright_cli_codegen_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright codegen"
@ -561,6 +576,7 @@ function test_playwright_cli_codegen_should_work {
function test_playwright_driver_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npm install ${PLAYWRIGHT_TGZ}
echo "Running playwright install"
@ -576,6 +592,7 @@ function test_playwright_driver_should_work {
function test_playwright_test_should_work {
initialize_test "${FUNCNAME[0]}"
npm install ${PLAYWRIGHT_CORE_TGZ}
npm install ${PLAYWRIGHT_TEST_TGZ}
copy_test_scripts

0
packages/installation-tests/playwright-test-types.ts → installation-tests/playwright-test-types.ts

0
packages/installation-tests/read-json-report.js → installation-tests/read-json-report.js

0
packages/installation-tests/sample.spec.js → installation-tests/sample.spec.js

0
packages/installation-tests/sanity-electron.js → installation-tests/sanity-electron.js

4
packages/installation-tests/sanity.js → installation-tests/sanity.js

@ -32,8 +32,8 @@ else if (process.argv[3])
const playwright = require(requireName);
// Requiring internals should work.
const errors = require(requireName + '/lib/utils/errors');
const registry = require(requireName + '/lib/utils/registry');
const errors = require('playwright-core/lib/utils/errors');
const registry = require('playwright-core/lib/utils/registry');
(async () => {
for (const browserType of success) {

0
packages/installation-tests/screencast.js → installation-tests/screencast.js

0
packages/installation-tests/validate-dependencies-skip-executable-path.js → installation-tests/validate-dependencies-skip-executable-path.js

0
packages/installation-tests/validate-dependencies.js → installation-tests/validate-dependencies.js

7405
package-lock.json

File diff suppressed because it is too large

69
package.json

@ -8,8 +8,12 @@
"engines": {
"node": ">=12"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"scripts": {
"basetest": "cross-env PWTEST_CLI_ALLOW_TEST_COMMAND=1 node ./lib/cli/cli test",
"basetest": "cross-env PWTEST_CLI_ALLOW_TEST_COMMAND=1 playwright test",
"ctest": "npm run basetest -- --config=tests/config/default.config.ts --project=chromium",
"ftest": "npm run basetest -- --config=tests/config/default.config.ts --project=firefox",
"wtest": "npm run basetest -- --config=tests/config/default.config.ts --project=webkit",
@ -19,11 +23,12 @@
"test": "npm run basetest -- --config=tests/config/default.config.ts",
"eslint": "[ \"$CI\" = true ] && eslint --quiet -f codeframe --ext ts,tsx . || eslint --ext ts,tsx .",
"tsc": "tsc -p .",
"build-installer": "babel -s --extensions \".ts\" --out-dir lib/utils/ src/utils",
"build-installer": "babel -s --extensions \".ts\" --out-dir packages/playwright-core/lib/utils/ packages/playwright-core/src/utils",
"doc": "node utils/doclint/cli.js",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run test-types",
"flint": "concurrently -s all \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run test-types\"",
"clean": "rimraf lib && rimraf src/generated/",
"lint": "npm run eslint && npm run tsc && npm run doc && npm run check-deps && node utils/generate_channels.js && node utils/generate_types/ --check-clean && npm run test-types && npm run lint-packages",
"lint-packages": "node utils/prepare_packages.js --check-clean",
"flint": "concurrently \"npm run eslint\" \"npm run tsc\" \"npm run doc\" \"npm run check-deps\" \"node utils/generate_channels.js\" \"node utils/generate_types/ --check-clean\" \"npm run test-types\" \"npm run lint-packages\"",
"clean": "rimraf packages/playwright-core/lib && rimraf packages/playwright-test/lib && rimraf packages/playwright-core/src/generated/",
"prepare": "node install-from-github.js",
"build": "node utils/build/build.js",
"watch": "node utils/build/build.js --watch --lint",
@ -32,57 +37,9 @@
"check-deps": "node utils/check_deps.js",
"build-android-driver": "./utils/build_android_driver.sh"
},
"author": {
"name": "Microsoft Corporation"
},
"license": "Apache-2.0",
"bin": {
"playwright": "./lib/cli/cli.js"
},
"DEPS-NOTE": "Any non-test dependency must be added to the build_package.js script as well",
"dependencies": {
"@babel/code-frame": "^7.14.5",
"@babel/core": "^7.14.8",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-dynamic-import": "^7.14.5",
"@babel/plugin-proposal-export-namespace-from": "^7.14.5",
"@babel/plugin-proposal-logical-assignment-operators": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.14.5",
"@babel/plugin-proposal-numeric-separator": "^7.14.5",
"@babel/plugin-proposal-optional-chaining": "^7.14.5",
"@babel/plugin-proposal-private-methods": "^7.14.5",
"@babel/plugin-proposal-private-property-in-object": "^7.14.5",
"@babel/plugin-syntax-async-generators": "^7.8.4",
"@babel/plugin-syntax-json-strings": "^7.8.3",
"@babel/plugin-syntax-object-rest-spread": "^7.8.3",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.3",
"@babel/plugin-transform-modules-commonjs": "^7.14.5",
"@babel/preset-typescript": "^7.14.5",
"colors": "^1.4.0",
"commander": "^8.2.0",
"debug": "^4.1.1",
"expect": "^27.2.5",
"extract-zip": "^2.0.1",
"https-proxy-agent": "^5.0.0",
"jest-matcher-utils": "^27.2.5",
"jpeg-js": "^0.4.2",
"mime": "^2.4.6",
"minimatch": "^3.0.3",
"ms": "^2.1.2",
"open": "^8.2.1",
"pirates": "^4.0.1",
"pixelmatch": "^5.2.1",
"pngjs": "^5.0.0",
"progress": "^2.0.3",
"proper-lockfile": "^4.1.1",
"proxy-from-env": "^1.1.0",
"rimraf": "^3.0.2",
"source-map-support": "^0.4.18",
"stack-utils": "^2.0.3",
"ws": "^7.4.6",
"yauzl": "^2.10.0",
"yazl": "^2.5.1"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"@babel/cli": "^7.14.8",
"@babel/plugin-transform-typescript": "^7.14.6",

48
packages/README.md

@ -1,48 +0,0 @@
# Managing and Publishing Playwright Packages
## Overview
- Playwright ships multiple packages to NPM. All packages that are published to NPM are listed as folders under [`//packages/`](../packages).
- Playwright's [root package.json](../package.json) is **never published to NPM**. It is only used for devmode, e.g. when running `npm install` with no arguments or installing from github.
- Playwright dependencies for all packages are the same and are managed with the [`root package.json`](../package.json).
- Playwright browser versions for all packages are the same and are managed with the [`browsers.json`](../browsers.json).
> **NOTE** As of May 20, 2020, the only exception is the `playwright-electron` package that
> doesn't follow the pack and is published manually. This is due to it's pre-1.0 status.
## Building NPM package
To build a package that will be shipped to NPM, use [`//packages/build_package.js`](./build_package.js) script.
The script populates package folder with contents, and then uses `npm pack` to archive the folder.
As of May 20, 2020, [`//packages/build_package.js`](./build_package.js) does the following:
- copies certain files and folders from `playwright-internal` to the subpackage (e.g. `//lib`, `//types`, `//LICENSE` etc)
- generates `package.json` and puts it in the subpackage
- generates `browsers.json` and puts it in the subpackage
- uses `npm pack` to pack the subpackage folder
- removes all the files that were added during the process
To build `playwright` package and save result as `./playwright.tgz` file:
```bash
./packages/build_package.js playwright ./playwright.tgz
```
To debug what files are put into the folder, use `--no-cleanup` flag and inspect the package folder:
```bash
./packages/build_package.js playwright ./playwright.tgz --no-cleanup
ls ./packages/playwright # inspect the folder
```
## Testing packages
To test packages, use [`//packages/installation-tests/installation-tests.sh`](./installation-tests/installation-tests.sh).
## Publishing packages
All package publishing happens **exclusively** over CI/CD using the [`//utils/publish_all_packages.sh`](../utils/publish_all_packages.sh) script.

229
packages/build_package.js

@ -1,229 +0,0 @@
#!/usr/bin/env node
/**
* Copyright (c) Microsoft Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const fs = require('fs');
const os = require('os');
const path = require('path');
const rmSync = require('rimraf').sync;
const ncp = require('ncp');
const {spawnSync} = require('child_process');
const util = require('util');
const writeFileAsync = util.promisify(fs.writeFile.bind(fs));
const cpAsync = util.promisify(ncp);
const SCRIPT_NAME = path.basename(__filename);
const ROOT_PATH = path.join(__dirname, '..');
const PLAYWRIGHT_CORE_FILES = ['bin', 'lib', 'types', 'NOTICE', 'LICENSE', ];
const PACKAGES = {
'playwright': {
description: 'A high-level API to automate web browsers',
browsers: ['chromium', 'firefox', 'webkit', 'ffmpeg'],
// We copy README.md additionally for Playwright so that it looks nice on NPM.
files: [...PLAYWRIGHT_CORE_FILES, 'README.md'],
},
'playwright-core': {
description: 'A high-level API to automate web browsers',
browsers: [],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-test': {
description: 'Playwright Test',
browsers: ['chromium', 'firefox', 'webkit', 'ffmpeg'],
files: PLAYWRIGHT_CORE_FILES,
name: '@playwright/test',
},
'playwright-webkit': {
description: 'A high-level API to automate WebKit',
browsers: ['webkit'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-firefox': {
description: 'A high-level API to automate Firefox',
browsers: ['firefox'],
files: PLAYWRIGHT_CORE_FILES,
},
'playwright-chromium': {
description: 'A high-level API to automate Chromium',
browsers: ['chromium', 'ffmpeg'],
files: PLAYWRIGHT_CORE_FILES,
},
};
const DEPENDENCIES = [
'commander',
'debug',
'extract-zip',
'https-proxy-agent',
'jpeg-js',
'mime',
'pngjs',
'progress',
'proper-lockfile',
'proxy-from-env',
'rimraf',
'stack-utils',
'ws',
'yazl',
];
// 1. Parse CLI arguments
const args = process.argv.slice(2);
if (args.some(arg => arg === '--help')) {
console.log(usage());
process.exit(1);
} else if (args.length < 1) {
console.log(`Please specify package name, e.g. 'playwright' or 'playwright-chromium'.`);
console.log(`Try running ${SCRIPT_NAME} --help`);
process.exit(1);
} else if (args.length < 2) {
console.log(`Please specify output path`);
console.log(`Try running ${SCRIPT_NAME} --help`);
process.exit(1);
}
const packageName = args[0];
const outputPath = path.resolve(args[1]);
const packagePath = path.join(__dirname, 'output', packageName);
const package = PACKAGES[packageName];
if (!package) {
console.log(`ERROR: unknown package ${packageName}`);
process.exit(1);
}
// 2. Setup cleanup if needed
if (!args.some(arg => arg === '--no-cleanup')) {
process.on('exit', () => {
rmSync(packagePath, {});
});
process.on('SIGINT', () => process.exit(2));
process.on('SIGHUP', () => process.exit(3));
process.on('SIGTERM', () => process.exit(4));
process.on('uncaughtException', error => {
console.error(error);
process.exit(5);
});
process.on('unhandledRejection', error => {
console.error(error);
process.exit(6);
});
}
(async () => {
// 3. Copy package files.
rmSync(packagePath, {});
fs.mkdirSync(packagePath, { recursive: true });
await copyToPackage(path.join(__dirname, 'common') + path.sep, packagePath + path.sep);
if (fs.existsSync(path.join(__dirname, packageName))) {
// Copy package-specific files, these can overwrite common ones.
await copyToPackage(path.join(__dirname, packageName) + path.sep, packagePath + path.sep);
}
for (const file of package.files)
await copyToPackage(path.join(ROOT_PATH, file), path.join(packagePath, file));
// 4. Generate package.json
const pwInternalJSON = require(path.join(ROOT_PATH, 'package.json'));
const depNames = packageName === 'playwright-test' ? Object.keys(pwInternalJSON.dependencies) : DEPENDENCIES;
const dependencies = {};
for (const dep of depNames) {
if (!pwInternalJSON.dependencies[dep])
throw new Error(`Dependecy ${dep} was removed from package.json, but not build_package.js`);
dependencies[dep] = pwInternalJSON.dependencies[dep];
}
await writeToPackage('package.json', JSON.stringify({
name: package.name || packageName,
version: pwInternalJSON.version,
description: package.description,
repository: pwInternalJSON.repository,
engines: pwInternalJSON.engines,
homepage: pwInternalJSON.homepage,
main: 'index.js',
bin: {
playwright: './lib/cli/cli.js',
},
exports: {
// Root import: we have a wrapper ES Module to support the following syntax.
// const { chromium } = require('playwright');
// import { chromium } from 'playwright';
'.': {
import: './index.mjs',
require: './index.js',
},
// Anything else can be required/imported by providing a relative path.
'./': './',
},
scripts: {
install: 'node install.js',
},
author: pwInternalJSON.author,
license: pwInternalJSON.license,
dependencies,
}, null, 2));
// 5. Generate browsers.json
const browsersJSON = require(path.join(ROOT_PATH, 'browsers.json'));
for (const browser of browsersJSON.browsers)
browser.installByDefault = package.browsers.includes(browser.name);
await writeToPackage('browsers.json', JSON.stringify(browsersJSON, null, 2));
// 6. Bake commit SHA into the package
const commitSHA = spawnSync('git', ['rev-parse', 'HEAD'], {cwd: __dirname, encoding: 'utf8'});
await writeToPackage('commitinfo', commitSHA.stdout.trim());
// 7. Run npm pack
const shell = os.platform() === 'win32';
const {stdout, stderr, status} = spawnSync('npm', ['pack'], {cwd: packagePath, encoding: 'utf8', shell});
if (status !== 0) {
console.log(`ERROR: "npm pack" failed`);
console.log(stderr);
process.exit(1);
}
const tgzName = stdout.trim();