From ffe2af2621e06254e3793860b23162a845ddc271 Mon Sep 17 00:00:00 2001 From: Kohei Watanabe Date: Thu, 24 Oct 2024 21:31:42 +0900 Subject: [PATCH] create playwright --- .gitignore | 1 + playwright/inner-text.test.ts | 21 +++++++++ playwright/package-lock.json | 75 +++++++++++++++++++++++++++++++++ playwright/package.json | 8 ++++ playwright/playwright.config.ts | 18 ++++++++ playwright/test.html | 15 +++++++ 6 files changed, 138 insertions(+) create mode 100644 playwright/inner-text.test.ts create mode 100644 playwright/package-lock.json create mode 100644 playwright/package.json create mode 100644 playwright/playwright.config.ts create mode 100644 playwright/test.html diff --git a/.gitignore b/.gitignore index 396e397..61b8ad2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ dist/ +test-results/ .next/ .env diff --git a/playwright/inner-text.test.ts b/playwright/inner-text.test.ts new file mode 100644 index 0000000..7121899 --- /dev/null +++ b/playwright/inner-text.test.ts @@ -0,0 +1,21 @@ +import { expect, test } from "@playwright/test"; + +test("first", async ({ page }) => { + // @ts-ignore + await page.goto(`file:///${__dirname}/test.html`); + + // playwright test --browser=chromium : pass + // playwright test --browser=firefox : pass + // playwright test --browser=webkit : fail (return `1\n`) + expect(await page.innerText("first-test")).toBe(`1`); +}); + +test("second", async ({ page }) => { + // @ts-ignore + await page.goto(`file:///${__dirname}/test.html`); + + // playwright test --browser=chromium : pass + // playwright test --browser=firefox : pass + // playwright test --browser=webkit : fail (return `2\n`) + expect(await page.innerText("second-test")).toBe(`2`); +}); diff --git a/playwright/package-lock.json b/playwright/package-lock.json new file mode 100644 index 0000000..877a14f --- /dev/null +++ b/playwright/package-lock.json @@ -0,0 +1,75 @@ +{ + "name": "playwright", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "devDependencies": { + "@playwright/test": "^1.48.1" + } + }, + "node_modules/@playwright/test": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.48.1.tgz", + "integrity": "sha512-s9RtWoxkOLmRJdw3oFvhFbs9OJS0BzrLUc8Hf6l2UdCNd1rqeEyD4BhCJkvzeEoD1FsK4mirsWwGerhVmYKtZg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright": "1.48.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + } + }, + "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, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/playwright": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.48.1.tgz", + "integrity": "sha512-j8CiHW/V6HxmbntOfyB4+T/uk08tBy6ph0MpBXwuoofkSnLmlfdYNNkFTYD6ofzzlSqLA1fwH4vwvVFvJgLN0w==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "playwright-core": "1.48.1" + }, + "bin": { + "playwright": "cli.js" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "fsevents": "2.3.2" + } + }, + "node_modules/playwright-core": { + "version": "1.48.1", + "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.48.1.tgz", + "integrity": "sha512-Yw/t4VAFX/bBr1OzwCuOMZkY1Cnb4z/doAFSwf4huqAGWmf9eMNjmK7NiOljCdLmxeRYcGPPmcDgU0zOlzP0YA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "playwright-core": "cli.js" + }, + "engines": { + "node": ">=18" + } + } + } +} diff --git a/playwright/package.json b/playwright/package.json new file mode 100644 index 0000000..bfab170 --- /dev/null +++ b/playwright/package.json @@ -0,0 +1,8 @@ +{ + "scripts": { + "test": "playwright test" + }, + "devDependencies": { + "@playwright/test": "^1.48.1" + } +} diff --git a/playwright/playwright.config.ts b/playwright/playwright.config.ts new file mode 100644 index 0000000..5d27525 --- /dev/null +++ b/playwright/playwright.config.ts @@ -0,0 +1,18 @@ +import { defineConfig, devices } from "@playwright/test"; + +export default defineConfig({ + projects: [ + { + name: "chromium", + use: devices["Desktop Chrome"], + }, + { + name: "firefox", + use: devices["Desktop Firefox"], + }, + { + name: "webkit", + use: devices["Desktop Safari"], + }, + ], +}); diff --git a/playwright/test.html b/playwright/test.html new file mode 100644 index 0000000..aa4cc53 --- /dev/null +++ b/playwright/test.html @@ -0,0 +1,15 @@ + + + + + + Document + + +
1
+ +
2
+
+
+ +