Skip to content

Commit 1f929e7

Browse files
Add Vitest and Playwright testing setup (#78)
Add Vitest and Playwright testing setup for easier more predictable development. In addition, utilise mise for managing setup and environment. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Co-authored-by: Martin Pengelly-Phillips <dev@thisbeyond.com>
1 parent b19f6b9 commit 1f929e7

14 files changed

Lines changed: 2423 additions & 2025 deletions

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
node_modules
22
types
33
dist
4-
.vscode
4+
.vscode
5+
playwright-report
6+
test-results

mise.toml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
[tools]
2+
node = "lts"
3+
pnpm = "latest"
4+
5+
[hooks]
6+
postinstall = 'npx corepack enable'
7+
8+
[env]
9+
_.path = ['./node_modules/.bin']
10+
11+
[tasks.pnpm-install]
12+
description = 'Installs dependencies with pnpm'
13+
run = 'pnpm install'
14+
sources = ['package.json', 'pnpm-lock.yaml', 'mise.toml']
15+
outputs = ['node_modules/.pnpm/lock.yaml']
16+
17+
[tasks.build]
18+
run = 'pnpm run build'
19+
20+
[tasks.dev]
21+
run = 'pnpm run dev'
22+
description = "Starts development server"
23+
24+
[tasks.playground]
25+
run = 'pnpm run dev:playground'
26+
description = "Starts the playground"
27+
28+
[tasks.update]
29+
run = 'pnpm update --latest --interactive'
30+
31+
[tasks.test]
32+
run = 'pnpm run test'
33+
depends = ['pnpm-install']
34+
35+
[tasks.playwright-install]
36+
run = 'pnpm exec playwright install'
37+
description = 'Installs playwright browsers'
38+
39+
[tasks."test:e2e"]
40+
run = 'pnpm run test:e2e'
41+
depends = ['pnpm-install', 'playwright-install']
42+
43+
[tasks.release]
44+
run = 'pnpm run release'
45+
description = "Release a new version"

package.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@
5555
"scripts": {
5656
"build": "tsup",
5757
"dev": "tsup --watch",
58+
"dev:playground": "vite playground",
59+
"test": "vitest",
60+
"test:e2e": "playwright test",
5861
"prepublishOnly": "pnpm run build",
5962
"release": "release-it"
6063
},
@@ -66,13 +69,22 @@
6669
"solid-js": "^1.8"
6770
},
6871
"devDependencies": {
72+
"@playwright/test": "^1.57.0",
6973
"@release-it/keep-a-changelog": "^5.0.0",
74+
"@solidjs/testing-library": "^0.8.10",
75+
"@testing-library/jest-dom": "^6.9.1",
76+
"@testing-library/user-event": "^14.6.1",
77+
"@types/node": "^25.0.6",
78+
"jsdom": "^24.1.3",
7079
"prettier": "^3.3.2",
7180
"release-it": "^17.4.0",
7281
"solid-js": "^1.8",
7382
"tsup": "^8.1.0",
7483
"tsup-preset-solid": "^2.2.0",
75-
"typescript": "^5.5.2"
84+
"typescript": "^5.5.2",
85+
"vite": "^5.4.21",
86+
"vite-plugin-solid": "^2.11.10",
87+
"vitest": "^2.1.9"
7688
},
7789
"publishConfig": {
7890
"access": "public"

playground/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1" />
6+
<title>Solid Select Playground</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/main.tsx"></script>
11+
</body>
12+
</html>

playground/main.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { render } from "solid-js/web";
2+
import { Select } from "@thisbeyond/solid-select";
3+
import "../public/style.css";
4+
5+
const App = () => {
6+
return (
7+
<div>
8+
<h1>Solid Select Playground</h1>
9+
<Select
10+
options={["Apple", "Banana", "Cherry"]}
11+
placeholder="Choose a fruit..."
12+
/>
13+
</div>
14+
);
15+
};
16+
17+
render(() => <App />, document.getElementById("root")!);

playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

playground/vite.config.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { defineConfig } from "vite";
2+
import solidPlugin from "vite-plugin-solid";
3+
import path from "path";
4+
5+
export default defineConfig({
6+
plugins: [solidPlugin()],
7+
resolve: {
8+
alias: {
9+
"@thisbeyond/solid-select": path.resolve(__dirname, "../src/index.tsx"),
10+
},
11+
},
12+
server: {
13+
port: 3000,
14+
},
15+
});

playwright.config.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
export default defineConfig({
4+
testDir: './tests/e2e',
5+
fullyParallel: true,
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
workers: process.env.CI ? 1 : undefined,
9+
reporter: 'html',
10+
use: {
11+
baseURL: 'http://localhost:3000',
12+
trace: 'on-first-retry',
13+
},
14+
projects: [
15+
{
16+
name: 'chromium',
17+
use: { ...devices['Desktop Chrome'] },
18+
},
19+
],
20+
webServer: {
21+
command: 'pnpm run dev:playground',
22+
url: 'http://localhost:3000',
23+
reuseExistingServer: !process.env.CI,
24+
},
25+
});

0 commit comments

Comments
 (0)