Skip to content

Commit e2958bf

Browse files
feat: Migration to Playwright (#6590)
* Playwright setup + 4 specs migrated Playwright setup * Remove Playwright from Credits * chore: sync package and lock * chore: install chromium at CI * chore: nx cloud doesn't work on CI * chore: install chromium in GA * chore: include nx cloud token * chore: install deps for full e2e --------- Co-authored-by: Dmitriy Shekhovtsov valorkin <[email protected]>
1 parent 6cd3af3 commit e2958bf

31 files changed

+26318
-21323
lines changed

.github/workflows/on-push-or-pull.yml

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ env:
1313
MOZ_HEALESS: 1
1414
SAUCE_USERNAME_PR: valorkinpr
1515
SAUCE_ACCESS_KEY_PR: e0a97bd3-4b74-4408-89bf-cce1b44a8bf1
16-
CYPRESS_CACHE_FOLDER: 'node_modules/.cypress'
17-
CYPRESS_RECORD_KEY: 4aa7a1c0-3a4f-444e-b324-6fc305a543a8
1816
FIREBASE_CHANNEL: ${{ fromJSON('["", "live"]')[!github.base_ref] }}
17+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 0
1918

2019
CACHE_NODE_MODULES_PATH: |
2120
~/.npm
@@ -118,21 +117,16 @@ jobs:
118117
channelId: ${{ env.FIREBASE_CHANNEL }}
119118
expires: 7d
120119

121-
# run cypress
120+
# run playwright
122121
e2e_smoke:
123-
name: e2e smoke
122+
name: e2e smoke (${{ matrix.shard }}/${{ strategy.job-total }})
124123
runs-on: ubuntu-latest
125124
needs: [install, build, firebase_preview]
126125

127126
strategy:
128-
# when one test fails, DO NOT cancel the other
129-
# containers, because this will kill Cypress processes
130-
# leaving the Dashboard hanging ...
131-
# https://github.com/cypress-io/github-action/issues/48
132127
fail-fast: false
133128
matrix:
134-
# run 3 copies of the current job in parallel
135-
containers: [1, 2, 3, 4, 5]
129+
shard: [1, 2]
136130
steps:
137131
- uses: actions/checkout@v2
138132
- uses: actions/cache@v2
@@ -144,30 +138,35 @@ jobs:
144138
path: ${{ env.CACHE_DIST_PATH }}
145139
key: dist-${{ github.run_id }}
146140

147-
# because of "record" and "parallel" parameters
148-
# these containers will load balance all found tests among themselves
141+
- name: Install playwright browsers
142+
run: |
143+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx playwright install
144+
npx playwright install-deps chromium
145+
149146
- name: smoke e2e on firebase
150147
if: ${{ needs.firebase_preview.outputs.output_url }}
151-
run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration firebase --runner cloud --record --group smoke --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --parallel
148+
run: npx nx run ngx-bootstrap-docs-e2e:e2e --pwProject=chromium-integration --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --skipServe --shard=${{ matrix.shard }}/${{ strategy.job-total }}
152149

153150
- name: smoke e2e local
154151
if: ${{ !needs.firebase_preview.outputs.output_url }}
155-
run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration production --runner cloud --record --group smoke --parallel
152+
run: npx nx run ngx-bootstrap-docs-e2e:e2e --pwProject=chromium-integration --shard=${{ matrix.shard }}/${{ strategy.job-total }}
153+
154+
- uses: actions/upload-artifact@v3
155+
if: always()
156+
with:
157+
name: playwright-report-${{ matrix.shard }}_${{ strategy.job-total }}
158+
path: playwright-report
159+
retention-days: 30
156160

157161
e2e_full:
158162
name: e2e full
159163
runs-on: ubuntu-latest
160164
needs: [e2e_smoke]
161165

162166
strategy:
163-
# when one test fails, DO NOT cancel the other
164-
# containers, because this will kill Cypress processes
165-
# leaving the Dashboard hanging ...
166-
# https://github.com/cypress-io/github-action/issues/48
167167
fail-fast: false
168168
matrix:
169-
# run 3 copies of the current job in parallel
170-
containers: [1, 2, 3, 4, 5]
169+
shard: [1, 2]
171170
steps:
172171
- uses: actions/checkout@v2
173172
- uses: actions/cache@v2
@@ -179,14 +178,24 @@ jobs:
179178
path: ${{ env.CACHE_DIST_PATH }}
180179
key: dist-${{ github.run_id }}
181180

182-
# because of "record" and "parallel" parameters
183-
# these containers will load balance all found tests among themselves
181+
- name: Install playwright browsers
182+
run: |
183+
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 npx playwright install
184+
npx playwright install-deps chromium
185+
184186
- name: full e2e on firebase
185187
if: ${{ needs.firebase_preview.outputs.output_url }}
186188
continue-on-error: true
187-
run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration firebase --runner cloud --cypressConfig ./apps/ngx-bootstrap-docs-e2e/cypress-full.json --record --group full --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --parallel
189+
run: npx nx run ngx-bootstrap-docs-e2e:e2e --pwProject=chromium-full --baseUrl=${{ needs.firebase_preview.outputs.output_url }}/ngx-bootstrap/ --skipServe --shard=${{ matrix.shard }}/${{ strategy.job-total }}
188190

189191
- name: full e2e on local
190192
if: ${{ !needs.firebase_preview.outputs.output_url }}
191193
continue-on-error: true
192-
run: npx nx run ngx-bootstrap-docs-e2e:e2e -- --configuration production --runner cloud --cypressConfig ./apps/ngx-bootstrap-docs-e2e/cypress-full.json --record --group full --parallel
194+
run: npx nx run ngx-bootstrap-docs-e2e:e2e --pwProject=chromium-full --shard=${{ matrix.shard }}/${{ strategy.job-total }}
195+
196+
- uses: actions/upload-artifact@v3
197+
if: always()
198+
with:
199+
name: playwright-report-${{ matrix.shard }}_${{ strategy.job-total }}
200+
path: playwright-report
201+
retention-days: 30

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,8 @@ scully.log
5050
/schematics/**/*.js
5151
/schematics/**/*.js.map
5252
/schematics/**/*.d.ts
53+
54+
# Playwright
55+
**/test-results/
56+
**/playwright-report/
57+
**/playwright/.cache/

README.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,7 @@ Please read our [contribution guidelines](https://github.com/valor-software/ngx-
199199

200200
### Credits
201201
Crossbrowser testing sponsored by [Saucelabs](https://saucelabs.com/)
202-
[<img src="https://avatars2.githubusercontent.com/u/88837?s=200&v=4" alt="Saucelabs" width="31" height="31">](https://saucelabs.com/)
203-
204-
End-to-end testing sponsored by [Cypress](https://www.cypress.io/)
205-
[<img src="https://raw.githubusercontent.com/cypress-io/cypress-icons/master/src/favicon/favicon.ico" alt="Cypress" width="31" height="31">](https://www.cypress.io/)
202+
[<img src="https://avatars2.githubusercontent.com/u/88837?s=200&v=4" alt="Saucelabs" width="31" height="31" align="middle">](https://saucelabs.com/)
206203

207204
### License
208205

angular.json

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1478,16 +1478,18 @@
14781478
]
14791479
},
14801480
"ngx-bootstrap-docs-e2e": {
1481-
"$schema": "../../node_modules/nx/schemas/project-schema.json",
14821481
"root": "apps/ngx-bootstrap-docs-e2e",
1483-
"sourceRoot": "apps/ngx-bootstrap-docs-e2e/src",
14841482
"projectType": "application",
1483+
"sourceRoot": "apps/ngx-bootstrap-docs-e2e/src",
14851484
"architect": {
14861485
"e2e": {
1487-
"builder": "@nrwl/cypress:cypress",
1486+
"builder": "@nxkit/playwright:test",
1487+
"outputs": [
1488+
"{options.outputPath}"
1489+
],
14881490
"options": {
1489-
"cypressConfig": "apps/ngx-bootstrap-docs-e2e/cypress.json",
1490-
"tsConfig": "apps/ngx-bootstrap-docs-e2e/tsconfig.e2e.json",
1491+
"outputPath": "dist/apps/ngx-bootstrap-docs-e2e/test-results",
1492+
"playwrightConfig": "apps/ngx-bootstrap-docs-e2e/playwright.config.ts",
14911493
"devServerTarget": "ngx-bootstrap-docs:serve"
14921494
},
14931495
"configurations": {
@@ -1499,15 +1501,42 @@
14991501
}
15001502
}
15011503
},
1504+
"debug": {
1505+
"builder": "@nxkit/playwright:test",
1506+
"outputs": [
1507+
"{options.outputPath}"
1508+
],
1509+
"options": {
1510+
"outputPath": "dist/apps/ngx-bootstrap-docs-e2e/test-results",
1511+
"playwrightConfig": "apps/ngx-bootstrap-docs-e2e/playwright.config.ts",
1512+
"devServerTarget": "ngx-bootstrap-docs:serve",
1513+
"debug": true
1514+
},
1515+
"configurations": {
1516+
"production": {
1517+
"devServerTarget": "ngx-bootstrap-docs:serve:production"
1518+
}
1519+
}
1520+
},
1521+
"show-report": {
1522+
"builder": "@nxkit/playwright:show-report",
1523+
"options": {
1524+
"reportPath": "dist/apps/ngx-bootstrap-docs-e2e/playwright-report"
1525+
}
1526+
},
15021527
"lint": {
15031528
"builder": "@nrwl/linter:eslint",
1529+
"outputs": [
1530+
"{options.outputFile}"
1531+
],
15041532
"options": {
15051533
"lintFilePatterns": [
15061534
"apps/ngx-bootstrap-docs-e2e/**/*.{js,ts}"
15071535
]
15081536
}
15091537
}
15101538
},
1539+
"tags": [],
15111540
"implicitDependencies": [
15121541
"ngx-bootstrap-docs"
15131542
]
Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,33 @@
11
{
2-
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
3-
"ignorePatterns": ["!**/*"],
4-
"rules": {},
2+
"extends": [
3+
"../../.eslintrc.json"
4+
],
5+
"ignorePatterns": [
6+
"!**/*"
7+
],
58
"overrides": [
69
{
7-
"files": ["src/plugins/index.js"],
8-
"rules": {
9-
"@typescript-eslint/no-var-requires": "off",
10-
"no-undef": "off"
11-
}
10+
"files": [
11+
"*.ts",
12+
"*.tsx",
13+
"*.js",
14+
"*.jsx"
15+
],
16+
"rules": {}
17+
},
18+
{
19+
"files": [
20+
"*.ts",
21+
"*.tsx"
22+
],
23+
"rules": {}
24+
},
25+
{
26+
"files": [
27+
"*.js",
28+
"*.jsx"
29+
],
30+
"rules": {}
1231
}
1332
]
1433
}

apps/ngx-bootstrap-docs-e2e/cypress-full.json

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

apps/ngx-bootstrap-docs-e2e/cypress.json

Lines changed: 0 additions & 18 deletions
This file was deleted.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testMatch: '**/*.spec.ts',
5+
fullyParallel: true,
6+
workers: 3,
7+
reporter: [['html', { outputFolder: 'playwright-report', open: 'never' }]],
8+
use: {
9+
baseURL: 'http://localhost:4200/ngx-bootstrap/',
10+
headless: true
11+
},
12+
13+
projects: [
14+
{
15+
name: 'chromium-integration',
16+
use: { ...devices['Desktop Chrome'] },
17+
testDir: './src/integration'
18+
},
19+
{
20+
name: 'chromium-full',
21+
use: { ...devices['Desktop Chrome'] },
22+
testDir: './src/full'
23+
},
24+
{
25+
name: 'chromium-all',
26+
use: { ...devices['Desktop Chrome'] },
27+
testDir: './src'
28+
}
29+
],
30+
});

apps/ngx-bootstrap-docs-e2e/src/fixtures/example.json

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

0 commit comments

Comments
 (0)