feat: Change e2e to be Playwright

Signed-off-by: Avior <github@avior.me>
This commit is contained in:
Florian Bouillon 2023-07-20 21:33:55 +02:00
parent db6236d8d8
commit 9a17362de3
12 changed files with 148 additions and 1924 deletions

View File

@ -28,8 +28,8 @@ jobs:
- name: Check
run: npm run check
- name: Prepare Tests
run: npm run install:tests
- name: Test
run : |
npm run start &
sleep 10
npm run test
run : npm run test

3
.gitignore vendored
View File

@ -24,3 +24,6 @@ slicers/*
# Coverage
coverage/
# Playwright
/playwright/

View File

@ -1,7 +0,0 @@
import { defineConfig } from 'cypress'
export default defineConfig({
e2e: {
supportFile: false
}
})

2
cypress/.gitignore vendored
View File

@ -1,2 +0,0 @@
videos
screenshots

View File

@ -1,5 +0,0 @@
# Cypress
Hold End2End tests
currently WIP

View File

@ -1,5 +0,0 @@
it('titles are correct', () => {
const page = cy.visit('http://localhost:3000');
page.get('h1').should('have.text', 'Welcome to Astro');
})

View File

@ -1,8 +0,0 @@
{
"compilerOptions": {
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "node"]
},
"include": ["**/*.ts"]
}

5
e2e/README.md Normal file
View File

@ -0,0 +1,5 @@
# e2e
Hold End 2 End tests
currently WIP

8
e2e/example.spec.ts Normal file
View File

@ -0,0 +1,8 @@
import { expect, test } from '@playwright/test'
test('has title', async ({ page }) => {
await page.goto('/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Astro/);
})

1893
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,32 +1,34 @@
{
"name": "@fi3d/slicer-as-a-service",
"type": "module",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "node ./dist/server/entry.mjs",
"build": "astro build",
"check": "npm run check:astro && npm run check:typescript",
"check:astro": "astro check",
"check:typescript": "tsc --noEmit",
"test": "npm run test:unit && npm run test:integ",
"test:unit": "vitest --coverage --run",
"test:integ": "cypress run --headless --browser chromium"
},
"dependencies": {
"@astrojs/node": "^5",
"@astrojs/tailwind": "^4",
"@dzeio/logger": "^3",
"@dzeio/object-util": "^1",
"@dzeio/url-manager": "^1",
"astro": "^2",
"lucide-astro": "^0.262.0",
"tailwindcss": "^3"
},
"devDependencies": {
"@types/node": "^20",
"@vitest/coverage-v8": "^0.33.0",
"cypress": "^12",
"vitest": "^0.33.0"
}
}
{
"name": "@fi3d/slicer-as-a-service",
"type": "module",
"private": true,
"scripts": {
"dev": "astro dev",
"start": "node ./dist/server/entry.mjs",
"build": "astro build",
"check": "npm run check:astro && npm run check:typescript",
"check:astro": "astro check",
"check:typescript": "tsc --noEmit",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "vitest --coverage --run",
"test:e2e": "playwright test",
"install:test": "playwright install --with-deps"
},
"dependencies": {
"@astrojs/node": "^5",
"@astrojs/tailwind": "^4",
"@dzeio/logger": "^3",
"@dzeio/object-util": "^1",
"@dzeio/url-manager": "^1",
"astro": "^2",
"lucide-astro": "^0.262.0",
"tailwindcss": "^3"
},
"devDependencies": {
"@playwright/test": "^1.36.1",
"@types/node": "^20",
"@vitest/coverage-v8": "^0.33.0",
"vitest": "^0.33.0"
}
}

62
playwright.config.ts Normal file
View File

@ -0,0 +1,62 @@
import { defineConfig, devices } from '@playwright/test'
export default defineConfig({
webServer: {
command: 'npm run start',
url: 'http://localhost:3000',
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI
},
outputDir: './playwright/results',
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined as any,
reporter: process.env.CI ? 'list' : [['html', {
outputFolder: './playwright/report',
open: 'never'
}]],
use: {
baseURL: 'http://localhost:3000',
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
})