Skip to content

Commit 45b44ab

Browse files
updated: use playwright instead of wdio
1 parent badaeeb commit 45b44ab

File tree

8 files changed

+171
-338
lines changed

8 files changed

+171
-338
lines changed

.github/workflows/test.yml

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ jobs:
2424
- run: |
2525
npm run lint
2626
npm test
27+
- name: Install Playwright Browsers
28+
if: ${{ success() && github.event_name != 'pull_request' && matrix.node-version == '20.x' }}
29+
run: npx playwright install --with-deps
2730
- name: Runtime test
2831
if: ${{ success() && github.event_name != 'pull_request' && matrix.node-version == '20.x' }}
2932
run: |

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,7 @@ pids
7373
.nyc_output/
7474
.reify-cache/
7575
stats.html
76+
/test-results/
77+
/playwright-report/
78+
/blob-report/
79+
/playwright/.cache/

package-lock.json

+78-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-5
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"build": "rollup -c build/rollup.node.config.js && rollup -c build/rollup.browser.config.js && rollup -c build/rollup.essential.config.js",
3131
"postest": "npm run cov-html",
3232
"test-types": "tsc -p test",
33-
"test-runtime": "start-server-and-test serve 3000 wdio run ./wdio.conf.js",
33+
"test-runtime": "playwright test",
3434
"test-commonjs": "c8 mocha 'test/**/*.spec.cjs'",
3535
"test": "c8 mocha 'test/**/*.spec.js' && npm run test-types",
3636
"debug": "mocha --inspect --inspect-brk 'test/**/*.spec.js'",
@@ -51,16 +51,13 @@
5151
"devDependencies": {
5252
"@babel/core": "^7.23.9",
5353
"@babel/preset-env": "^7.23.9",
54+
"@playwright/test": "^1.41.2",
5455
"@riotjs/dom-bindings": "^9.0.4",
5556
"@riotjs/prettier-config": "^1.1.0",
5657
"@rollup/plugin-alias": "^5.1.0",
5758
"@rollup/plugin-commonjs": "^25.0.7",
5859
"@rollup/plugin-json": "^6.1.0",
5960
"@rollup/plugin-node-resolve": "^15.2.3",
60-
"@wdio/cli": "^8.32.3",
61-
"@wdio/local-runner": "^8.32.3",
62-
"@wdio/mocha-framework": "^8.32.3",
63-
"@wdio/spec-reporter": "^8.32.2",
6461
"acorn": "^8.11.3",
6562
"c8": "^9.1.0",
6663
"chai": "^5.1.0",

playwright.config.js

+79
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
// @ts-check
2+
import { defineConfig, devices } from '@playwright/test'
3+
4+
/**
5+
* Read environment variables from file.
6+
* https://github.com/motdotla/dotenv
7+
*/
8+
// require('dotenv').config();
9+
10+
/**
11+
* @see https://playwright.dev/docs/test-configuration
12+
*/
13+
export default defineConfig({
14+
testDir: './test/',
15+
testMatch: '*.e2e.js',
16+
/* Run tests in files in parallel */
17+
fullyParallel: true,
18+
/* Fail the build on CI if you accidentally left test.only in the source code. */
19+
forbidOnly: !!process.env.CI,
20+
/* Retry on CI only */
21+
retries: process.env.CI ? 2 : 0,
22+
/* Opt out of parallel tests on CI. */
23+
workers: process.env.CI ? 1 : undefined,
24+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
25+
reporter: 'html',
26+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
27+
use: {
28+
/* Base URL to use in actions like `await page.goto('/')`. */
29+
// baseURL: 'http://127.0.0.1:3000',
30+
31+
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
32+
trace: 'on-first-retry',
33+
},
34+
35+
/* Configure projects for major browsers */
36+
projects: [
37+
{
38+
name: 'chromium',
39+
use: { ...devices['Desktop Chrome'] },
40+
},
41+
42+
{
43+
name: 'firefox',
44+
use: { ...devices['Desktop Firefox'] },
45+
},
46+
47+
{
48+
name: 'webkit',
49+
use: { ...devices['Desktop Safari'] },
50+
},
51+
52+
/* Test against mobile viewports. */
53+
// {
54+
// name: 'Mobile Chrome',
55+
// use: { ...devices['Pixel 5'] },
56+
// },
57+
// {
58+
// name: 'Mobile Safari',
59+
// use: { ...devices['iPhone 12'] },
60+
// },
61+
62+
/* Test against branded browsers. */
63+
// {
64+
// name: 'Microsoft Edge',
65+
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
66+
// },
67+
// {
68+
// name: 'Google Chrome',
69+
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
70+
// },
71+
],
72+
73+
/* Run your local dev server before starting the tests */
74+
webServer: {
75+
command: 'npx serve',
76+
url: 'http://127.0.0.1:3000',
77+
reuseExistingServer: !process.env.CI,
78+
},
79+
})

test/karma.conf.cjs

-13
This file was deleted.

test/test.e2e.js

+5-11
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
1-
import { browser, expect } from '@wdio/globals'
1+
import { test, expect } from '@playwright/test'
22

3-
describe('Run the mocha tests', function () {
4-
it('All the mocha tests passed', async () => {
5-
await browser.url('http://localhost:3000/test/e2e.runtime.html')
6-
await browser.waitUntil(async () =>
7-
browser.execute(() => typeof window.testFailures === 'number'),
8-
)
9-
const testFailures = await browser.execute(() => window.testFailures)
3+
test('All the mocha tests passed', async ({ page }) => {
4+
await page.goto('http://localhost:3000/test/e2e.runtime.html')
5+
const testFailures = await page.evaluate('window.testFailures')
106

11-
expect(testFailures).toBe(0)
12-
expect(true).toBe(true)
13-
})
7+
expect(testFailures).toBe(0)
148
})

0 commit comments

Comments
 (0)