Skip to content

Commit

Permalink
playwright setup (#425)
Browse files Browse the repository at this point in the history
#392

Sets up playwright for E2E testing on the data portal. All tests will
need to be stored in the `e2e/` directory and will need the `.spec.ts`
extension
  • Loading branch information
codemonkey800 authored Jan 30, 2024
1 parent 26980ca commit 0141d70
Show file tree
Hide file tree
Showing 4 changed files with 125 additions and 0 deletions.
5 changes: 5 additions & 0 deletions frontend/packages/data-portal/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
node_modules/
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
4 changes: 4 additions & 0 deletions frontend/packages/data-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
"dev:codegen": "pnpm build:codegen -w",
"dev:remix": "remix dev --manual -c 'node --loader ts-node/esm --watch-path server.ts --watch server.ts'",
"dev:tcm": "pnpm build:tcm -w",
"e2e": "playwright test",
"e2e:debug": "playwright test --ui",
"lint": "pnpm build:codegen && run-p -l 'lint:!(fix)'",
"lint:fix": "run-p -l 'lint:*:fix'",
"lint:eslint": "eslint --report-unused-disable-directives --max-warnings 0 .",
Expand Down Expand Up @@ -88,6 +90,7 @@
},
"devDependencies": {
"@parcel/watcher": "^2.3.0",
"@playwright/test": "^1.41.1",
"@remix-run/dev": "^2.0.1",
"@tailwindcss/typography": "^0.5.10",
"@testing-library/jest-dom": "^6.1.4",
Expand All @@ -110,6 +113,7 @@
"eslint-plugin-cryoet-data-portal": "*",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"playwright": "^1.41.1",
"postcss": "^8.4.31",
"postcss-nesting": "^12.0.1",
"stylelint": "^15.10.3",
Expand Down
78 changes: 78 additions & 0 deletions frontend/packages/data-portal/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { defineConfig, devices } from '@playwright/test'

/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();

/**
* See https://playwright.dev/docs/test-configuration.
*/
// eslint-disable-next-line import/no-default-export
export default defineConfig({
testDir: './e2e',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
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' },
// },
],

/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
})
38 changes: 38 additions & 0 deletions frontend/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0141d70

Please sign in to comment.