-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add e2e tests for multi-example app (#120)
--------- Co-authored-by: gioboa <giorgiob.boa@gmail.com>
- Loading branch information
Showing
11 changed files
with
561 additions
and
184 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: multi-example - e2e tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
permissions: | ||
pull-requests: read | ||
|
||
jobs: | ||
run-playwright-tests: | ||
name: Playwright Tests | ||
runs-on: ubuntu-latest | ||
container: node:20 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Enable Corepack and Setup PNPM | ||
run: | | ||
corepack enable | ||
corepack prepare pnpm@9.1.3 --activate | ||
- name: Install Dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Install Chromium Browser | ||
run: pnpm playwright install --with-deps chromium | ||
|
||
- name: Build Projects | ||
run: pnpm build | ||
|
||
- name: Start Application multi-example | ||
run: nohup pnpm run multi-example & pnpm exec wait-on http://localhost:5173; | ||
|
||
- name: Run Playwright Tests | ||
run: pnpm playwright test | ||
|
||
- name: Upload Artifacts on Failure | ||
if: failure() | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: test-results | ||
path: reports/e2e/output | ||
retention-days: 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,4 +4,6 @@ dist | |
.idea | ||
.__mf__win | ||
lib | ||
**/.__mf__temp | ||
**/.__mf__temp | ||
reports/* | ||
nohup.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test.describe('Vite Host Tests', () => { | ||
test.beforeEach(async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
}); | ||
|
||
test('test header - vite host', async ({ page }) => { | ||
const womenButton = page.getByRole('button', { name: 'Women', exact: true }); | ||
const manButton = page.getByRole('button', { name: 'Man', exact: true }); | ||
const companyButton = page.getByRole('button', { name: 'Company', exact: true }); | ||
const storesButton = page.getByRole('button', { name: 'Stores', exact: true }); | ||
|
||
await Promise.all([ | ||
expect(womenButton).toBeVisible(), | ||
expect(manButton).toBeVisible(), | ||
expect(companyButton).toBeVisible(), | ||
expect(storesButton).toBeVisible(), | ||
]); | ||
}); | ||
|
||
test('test footer - vite host', async ({ page }) => { | ||
const productsHeading = page.getByRole('heading', { level: 3, name: 'Products', exact: true }); | ||
const companyHeading = page.getByRole('heading', { level: 3, name: 'Company', exact: true }); | ||
const customerServiceHeading = page.getByRole('heading', { | ||
level: 3, | ||
name: 'Customer Service', | ||
exact: true, | ||
}); | ||
|
||
await Promise.all([ | ||
expect(productsHeading).toBeVisible(), | ||
expect(companyHeading).toBeVisible(), | ||
expect(customerServiceHeading).toBeVisible(), | ||
]); | ||
}); | ||
}); | ||
|
||
test.describe('Vite remote', () => { | ||
test('has title', async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
const productHeader = page.getByRole('heading', { | ||
level: 1, | ||
name: 'Basic Tee', | ||
exact: true, | ||
}); | ||
await expect(productHeader).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.describe('Rspack remote', () => { | ||
test('has title', async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
const recentReviews = page.getByRole('heading', { | ||
level: 2, | ||
name: 'Recent reviews', | ||
exact: true, | ||
}); | ||
await expect(recentReviews).toBeVisible(); | ||
}); | ||
}); | ||
|
||
test.describe('Webpack remote', () => { | ||
test('has title', async ({ page, baseURL }) => { | ||
await page.goto(baseURL!); | ||
const furtherRecommendations = page.getByRole('heading', { | ||
level: 2, | ||
name: 'Customers also purchased', | ||
exact: true, | ||
}); | ||
await expect(furtherRecommendations).toBeVisible(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { defineConfig } from '@playwright/test'; | ||
|
||
export default defineConfig({ | ||
testDir: 'tests', | ||
timeout: 30 * 1000, | ||
retries: process.env.CI ? 2 : 0, | ||
workers: process.env.CI ? 1 : undefined, | ||
forbidOnly: Boolean(process.env.CI), | ||
use: { | ||
trace: 'retain-on-failure', | ||
screenshot: 'only-on-failure', | ||
video: 'retain-on-failure', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'multi-example', | ||
testDir: 'e2e/vite-webpack-rspack', | ||
use: { | ||
baseURL: 'http://localhost:5173', | ||
browserName: 'chromium', | ||
}, | ||
}, | ||
], | ||
outputDir: 'reports/e2e/output', | ||
reporter: [ | ||
['list'], | ||
['html', { outputFolder: 'reports/e2e/playwright-report', open: 'never' }], | ||
['json', { outputFile: 'reports/e2e/test-results.json' }], | ||
], | ||
}); |
Oops, something went wrong.