Skip to content

Commit 55fb419

Browse files
committed
Setup testing for nuxt app
1 parent 6482d4c commit 55fb419

6 files changed

Lines changed: 319 additions & 10 deletions

File tree

apps/web/package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,16 @@
77
"dev": "nuxt dev",
88
"generate": "nuxt generate",
99
"preview": "nuxt preview",
10-
"prepare": "nuxt prepare"
10+
"prepare": "nuxt prepare",
11+
"test": "vitest"
1112
},
1213
"devDependencies": {
1314
"@iconify-json/heroicons": "^1.2.3",
1415
"@iconify-json/lucide": "^1.2.81",
1516
"@iconify-json/simple-icons": "^1.2.63",
1617
"@nuxt/content": "^3.9.0",
1718
"@nuxt/image": "^2.0.0",
19+
"@nuxt/test-utils": "^3.21.0",
1820
"@nuxt/ui": "^4.3.0",
1921
"@nuxtjs/google-fonts": "^3.2.0",
2022
"@nuxtjs/sitemap": "^7.5.0",
@@ -23,13 +25,17 @@
2325
"@sentry/nuxt": "^10.32.0",
2426
"@types/numeral": "^2.0.5",
2527
"@types/semver": "^7.7.1",
28+
"@vue/test-utils": "^2.4.6",
2629
"@vueuse/core": "^14.1.0",
2730
"@vueuse/nuxt": "^14.1.0",
2831
"better-sqlite3": "^12.5.0",
2932
"dayjs": "^1.11.19",
33+
"happy-dom": "^20.0.11",
3034
"numeral": "^2.0.6",
3135
"nuxt": "^4.2.2",
36+
"playwright-core": "^1.57.0",
3237
"semver": "^7.7.3",
33-
"tailwindcss": "^4.1.18"
38+
"tailwindcss": "^4.1.18",
39+
"vitest": "^3.2.4"
3440
}
3541
}

apps/web/test/e2e/.gitkeep

Whitespace-only changes.

apps/web/test/nuxt/pages.test.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { setup, fetch } from "@nuxt/test-utils";
2+
import { describe, expect, test } from "vitest";
3+
4+
describe("pages", async () => {
5+
await setup({
6+
host: "http://localhost:3000"
7+
});
8+
9+
describe("basic", () => {
10+
testURL("/");
11+
testURL("/cookie-policy");
12+
testURL("/privacy-policy");
13+
testURL("/terms-of-service");
14+
});
15+
16+
const mods = getMods().toSorted((a, b) => a.url.localeCompare(b.url));
17+
18+
describe("landing", () => {
19+
for (const mod of mods) {
20+
testURL(mod.url);
21+
}
22+
});
23+
24+
describe("download", () => {
25+
for (const mod of mods) {
26+
testURL(`${mod.url}/download`);
27+
}
28+
});
29+
30+
describe("wiki", () => {
31+
testURL("/wiki");
32+
});
33+
});
34+
35+
function testURL(url: string) {
36+
test(`${url} renders`, async () => {
37+
const { status } = await fetch(url);
38+
expect(status).toBe(200);
39+
});
40+
}

apps/web/test/unit/.gitkeep

Whitespace-only changes.

apps/web/vitest.config.mts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { defineConfig } from "vitest/config";
2+
import { defineVitestProject } from "@nuxt/test-utils/config";
3+
4+
export default defineConfig({
5+
test: {
6+
projects: [
7+
{
8+
test: {
9+
name: "unit",
10+
include: ["test/{e2e,unit}/*.{test,spec}.ts"],
11+
environment: "node"
12+
}
13+
},
14+
await defineVitestProject({
15+
test: {
16+
name: "nuxt",
17+
include: ["test/nuxt/*.{test,spec}.ts"],
18+
environment: "nuxt"
19+
}
20+
})
21+
]
22+
}
23+
});

0 commit comments

Comments
 (0)