diff --git a/package-lock.json b/package-lock.json index 4a9b6b8c..fa8ae859 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "@nypl/web-reader", - "version": "4.3.2", + "version": "4.3.3", "license": "MIT", "dependencies": { "@chakra-ui/react": "2.8.1", @@ -23,6 +23,7 @@ "@babel/core": "7.24.3", "@emotion/jest": "11.11.0", "@parcel/transformer-typescript-tsc": "2.12.0", + "@playwright/test": "1.43.1", "@testing-library/cypress": "8.0.2", "@testing-library/jest-dom": "6.1.3", "@testing-library/react": "14.0.0", @@ -6165,6 +6166,21 @@ "node": ">=14" } }, + "node_modules/@playwright/test": { + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.43.1.tgz", + "integrity": "sha512-HgtQzFgNEEo4TE22K/X7sYTYNqEMMTZmFS8kTq6m8hXj+m1D8TgwgIbumHddJa9h4yl4GkKb8/bgAl2+g7eDgA==", + "dev": true, + "dependencies": { + "playwright": "1.43.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, "node_modules/@pnpm/config.env-replace": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@pnpm/config.env-replace/-/config.env-replace-1.1.0.tgz", @@ -20594,6 +20610,50 @@ "node": ">=8" } }, + "node_modules/playwright": { + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.43.1.tgz", + "integrity": "sha512-V7SoH0ai2kNt1Md9E3Gwas5B9m8KR2GVvwZnAI6Pg0m3sh7UvgiYhRrhsziCmqMJNouPckiOhk8T+9bSAK0VIA==", + "dev": true, + "dependencies": { + "playwright-core": "1.43.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=16" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.43.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.43.1.tgz", + "integrity": "sha512-EI36Mto2Vrx6VF7rm708qSnesVQKbxEWvPrfA1IPY6HgczBplDx7ENtx+K2n4kJ41sLLkuGfmb0ZLSSXlDhqPg==", + "dev": true, + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/playwright/node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/please-upgrade-node": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.2.0.tgz", diff --git a/package.json b/package.json index 861175f5..b10ce0d5 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "cypress:open": "cypress open", "cypress:run": "cypress run", "cypress:run:chrome": "cypress run --browser chrome", + "playwright": "playwright test", "prettier": "prettier --write --ignore-path .eslintignore .", "prettier:check": "prettier --check --ignore-path .eslintignore .", "lint": "eslint --fix .", @@ -70,6 +71,7 @@ "@babel/core": "7.24.3", "@emotion/jest": "11.11.0", "@parcel/transformer-typescript-tsc": "2.12.0", + "@playwright/test": "1.43.1", "@testing-library/cypress": "8.0.2", "@testing-library/jest-dom": "6.1.3", "@testing-library/react": "14.0.0", diff --git a/playwright.config.ts b/playwright.config.ts new file mode 100644 index 00000000..f6e30d4a --- /dev/null +++ b/playwright.config.ts @@ -0,0 +1,42 @@ +import { defineConfig, devices } from '@playwright/test'; + +export default defineConfig({ + // Look for test files in the "tests" directory, relative to this configuration file. + testDir: 'playwright/integration', + + // Run all tests 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 + reporter: 'html', + + use: { + // Base URL to use in actions like `await page.goto('/')`. + baseURL: 'http://127.0.0.1:1234', + }, + // Configure projects for major browsers. + projects: [ + { + name: 'chromium', + use: { + ...devices['Desktop Chrome'], + }, + }, + ], + // You can either build the app and let playwright start the prod server, + // or run a dev server and playwright will use that instead. + webServer: { + command: 'npm run example', + url: 'http://127.0.0.1:1234', + reuseExistingServer: !process.env.CI, + }, +}); diff --git a/playwright/integration/basic-test.spec.ts b/playwright/integration/basic-test.spec.ts new file mode 100644 index 00000000..e595ff1d --- /dev/null +++ b/playwright/integration/basic-test.spec.ts @@ -0,0 +1,8 @@ +// basic test for iniial setup +import { test, expect } from '@playwright/test'; + +test('basic test', async ({ page }) => { + await page.goto('https://playwright.dev/'); + await page.locator('text=Get started').click(); + await expect(page).toHaveTitle(/Installation | Playwright/); +});