Skip to content

Commit 515e7dc

Browse files
committed
Add e2e framework
1 parent dfa4579 commit 515e7dc

File tree

9 files changed

+110
-7
lines changed

9 files changed

+110
-7
lines changed

.eslintrc.json

+5
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"plugin:jest/recommended",
1010
"plugin:jest-dom/recommended",
1111
"plugin:jsx-a11y/recommended",
12+
"plugin:playwright/recommended",
1213
"plugin:react/recommended",
1314
"plugin:react/jsx-runtime",
1415
"plugin:sonarjs/recommended",
@@ -87,6 +88,10 @@
8788
"import/newline-after-import": "error",
8889
"import/no-cycle": "off",
8990
"import/no-duplicates": "error",
91+
"import/no-extraneous-dependencies": [
92+
"error",
93+
{ "devDependencies": ["**/*.config.ts", "**/*.spec.ts", "**/*.spec.tsx"] }
94+
],
9095
"import/prefer-default-export": "off",
9196
"jsx-a11y/label-has-associated-control": [
9297
"error",

.github/workflows/main.yml

+13-6
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
name: Tests
22

3-
on: push
3+
on:
4+
push:
5+
branches: [main]
46

57
jobs:
68
tests:
9+
timeout-minutes: 60
710
runs-on: ubuntu-latest
811
steps:
912
- uses: actions/checkout@v3
1013
- uses: actions/setup-node@v3
1114
with:
1215
node-version: 18
13-
- name: Install Modules
14-
run: NODE_OPTIONS='--openssl-legacy-provider' yarn install
15-
- name: Run Build
16-
run: NODE_OPTIONS='--openssl-legacy-provider' yarn run build
17-
- name: Run Tests
16+
- name: Install Dependencies
17+
run: NODE_OPTIONS='--openssl-legacy-provider' yarn
18+
- name: Run Jest Unit Tests
1819
run: NODE_OPTIONS='--openssl-legacy-provider' yarn test
20+
- name: Run Build & Start
21+
run: NODE_OPTIONS='--openssl-legacy-provider' yarn start
22+
- name: Install Playwright Browsers
23+
run: yarn playwright install --with-deps
24+
- name: Run Playwright E2E Tests
25+
run: yarn e2e

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
node_modules
44
out
55

6+
test-results
7+
playwright-report
8+
playwright/.cache
9+
610
public/robots.txt
711
public/sitemap.xml
812
public/.index/*
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
test("should open start menu and see apps & power buttons", async ({
4+
page,
5+
}) => {
6+
await page.goto("/");
7+
8+
await page.getByLabel("Start").click();
9+
10+
await expect(page.getByLabel("All apps")).toBeVisible();
11+
await expect(page.getByLabel("Power")).toBeVisible();
12+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { expect, test } from "@playwright/test";
2+
3+
test("should open start menu and see folders", async ({ page }) => {
4+
await page.goto("/");
5+
6+
await page.getByLabel("Start").click();
7+
8+
await expect(page.getByLabel("Emulators")).toBeVisible();
9+
await expect(page.getByLabel("Games")).toBeVisible();
10+
});

jest.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module.exports = require("next/jest")()({
22
moduleDirectories: ["<rootDir>", "node_modules"],
33
testEnvironment: "jest-environment-jsdom",
4+
testPathIgnorePatterns: ["<rootDir>/e2e/"],
45
});

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"docker:build": "docker build -t daedalos .",
2525
"docker:run": "docker run -dp 3000:3000 --rm --name daedalos daedalos",
2626
"dev": "next dev",
27+
"e2e": "playwright test",
2728
"eslint": "eslint --report-unused-disable-directives .",
2829
"export": "next export",
2930
"prepare": "husky install",
@@ -78,6 +79,7 @@
7879
"7z-wasm": "^1.0.2",
7980
"@next/bundle-analyzer": "^13.4.8",
8081
"@next/eslint-plugin-next": "^13.4.8",
82+
"@playwright/test": "^1.36.0",
8183
"@testing-library/dom": "^9.3.1",
8284
"@types/gif.js": "^0.2.2",
8385
"@types/ini": "^1.3.31",
@@ -102,6 +104,7 @@
102104
"eslint-plugin-import": "^2.27.5",
103105
"eslint-plugin-jest": "^27.2.2",
104106
"eslint-plugin-jest-dom": "^5.0.1",
107+
"eslint-plugin-playwright": "^0.15.3",
105108
"eslint-plugin-prettier": "^5.0.0",
106109
"eslint-plugin-react-hooks": "^4.6.0",
107110
"eslint-plugin-sonarjs": "^0.19.0",

playwright.config.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { PlaywrightTestConfig } from "@playwright/test";
2+
import { devices } from "@playwright/test";
3+
4+
const PORT = process.env.PORT || 3000;
5+
const baseURL = `http://localhost:${PORT}`;
6+
7+
const config: PlaywrightTestConfig = {
8+
fullyParallel: true,
9+
projects: [
10+
{
11+
name: "chromium",
12+
use: { ...devices["Desktop Chrome"] },
13+
},
14+
15+
{
16+
name: "firefox",
17+
use: { ...devices["Desktop Firefox"] },
18+
},
19+
20+
{
21+
name: "webkit",
22+
use: { ...devices["Desktop Safari"] },
23+
},
24+
],
25+
reporter: "html",
26+
retries: process.env.CI ? 2 : 0,
27+
testDir: "./e2e",
28+
use: {
29+
baseURL,
30+
trace: "on-first-retry",
31+
},
32+
webServer: {
33+
command: "yarn dev",
34+
reuseExistingServer: !process.env.CI,
35+
url: baseURL,
36+
},
37+
workers: process.env.CI ? 1 : undefined,
38+
};
39+
40+
// ts-prune-ignore-next
41+
export default config;

yarn.lock

+21-1
Original file line numberDiff line numberDiff line change
@@ -1628,6 +1628,16 @@
16281628
picocolors "^1.0.0"
16291629
tslib "^2.5.0"
16301630

1631+
"@playwright/test@^1.36.0":
1632+
version "1.36.0"
1633+
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.36.0.tgz#df2c0b09bbd27016adf1892b0c3502c4ce88d307"
1634+
integrity sha512-yN+fvMYtiyLFDCQos+lWzoX4XW3DNuaxjBu68G0lkgLgC6BP+m/iTxJQoSicz/x2G5EsrqlZTqTIP9sTgLQerg==
1635+
dependencies:
1636+
"@types/node" "*"
1637+
playwright-core "1.36.0"
1638+
optionalDependencies:
1639+
fsevents "2.3.2"
1640+
16311641
"@polka/url@^1.0.0-next.20":
16321642
version "1.0.0-next.21"
16331643
resolved "https://registry.yarnpkg.com/@polka/url/-/url-1.0.0-next.21.tgz#5de5a2385a35309427f6011992b544514d559aa1"
@@ -3620,6 +3630,11 @@ eslint-plugin-jsx-a11y@^6.5.1:
36203630
object.fromentries "^2.0.6"
36213631
semver "^6.3.0"
36223632

3633+
eslint-plugin-playwright@^0.15.3:
3634+
version "0.15.3"
3635+
resolved "https://registry.yarnpkg.com/eslint-plugin-playwright/-/eslint-plugin-playwright-0.15.3.tgz#9fd8753688351bcaf41797eb6a7df8807fd5eb1b"
3636+
integrity sha512-LQMW5y0DLK5Fnpya7JR1oAYL2/7Y9wDiYw6VZqlKqcRGSgjbVKNqxraphk7ra1U3Bb5EK444xMgUlQPbMg2M1g==
3637+
36233638
eslint-plugin-prettier@^5.0.0:
36243639
version "5.0.0"
36253640
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.0.0.tgz#6887780ed95f7708340ec79acfdf60c35b9be57a"
@@ -4117,7 +4132,7 @@ fscreen@^1.0.2:
41174132
resolved "https://registry.yarnpkg.com/fscreen/-/fscreen-1.2.0.tgz#1a8c88e06bc16a07b473ad96196fb06d6657f59e"
41184133
integrity sha512-hlq4+BU0hlPmwsFjwGGzZ+OZ9N/wq9Ljg/sq3pX+2CD7hrJsX9tJgWWK/wiNTFM212CLHWhicOoqwXyZGGetJg==
41194134

4120-
fsevents@^2.3.2, fsevents@~2.3.2:
4135+
fsevents@2.3.2, fsevents@^2.3.2, fsevents@~2.3.2:
41214136
version "2.3.2"
41224137
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
41234138
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
@@ -6364,6 +6379,11 @@ playlist-parser@^0.0.12:
63646379
dependencies:
63656380
xmldom "0.1.16"
63666381

6382+
6383+
version "1.36.0"
6384+
resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.36.0.tgz#35d1ed5f364a31e58bc8f06688ab02d538b96eb6"
6385+
integrity sha512-7RTr8P6YJPAqB+8j5ATGHqD6LvLLM39sYVNsslh78g8QeLcBs5750c6+msjrHUwwGt+kEbczBj1XB22WMwn+WA==
6386+
63676387
pluralize@^8.0.0:
63686388
version "8.0.0"
63696389
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1"

0 commit comments

Comments
 (0)