Skip to content

Commit 8cf39cb

Browse files
authored
test: enhance test configuration with unit and integration workspaces (#72)
* fix: reorder commands in release script for consistency * test: enhance test configuration with unit and integration workspaces * test: add unit and integration test configurations for Vitest * test: tweak test timeout
1 parent aea2695 commit 8cf39cb

File tree

7 files changed

+40
-6
lines changed

7 files changed

+40
-6
lines changed

.husky/pre-commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
npm test
1+
pnpm test --project '*-unit'

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"scripts": {
2121
"build": "pnpm --if-present --recursive build",
22-
"release": "pnpm test && pnpm build && changeset publish",
22+
"release": "pnpm build && pnpm test && changeset publish",
2323
"format": "biome format --write ./packages/*/src",
2424
"lint": "biome check --write ./packages/*/src",
2525
"test": "vitest --run",
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineProject } from "vitest/config";
2+
import pkg from "./package.json";
3+
4+
export default defineProject({
5+
test: {
6+
name: `${pkg.name}-unit`,
7+
include: ["**/*.test.ts"],
8+
exclude: ["integration/**"],
9+
},
10+
});

packages/vite-plugin-react-router-amplify-hosting/integration/build.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { build, createProject, npmInstall, reactRouterConfig } from "./helpers/v
77
describe("build test", () => {
88
let cwd: string;
99

10-
test("vite 5", {timeout: 60_000}, async () => {
10+
test("vite 5", async () => {
1111
cwd = await createProject({}, "vite-5-template");
1212
const installReturns = await npmInstall({ cwd });
1313
console.log(installReturns.stderr.toString());
@@ -20,7 +20,7 @@ describe("build test", () => {
2020
expect((await stat(join(cwd, ".amplify-hosting", "static", "assets"))).isDirectory()).toBe(true);
2121
});
2222

23-
test("vite 6", {timeout: 60_000}, async () => {
23+
test("vite 6", async () => {
2424
cwd = await createProject({}, "vite-6-template");
2525
await npmInstall({ cwd });
2626
const returns = await build({
@@ -32,7 +32,7 @@ describe("build test", () => {
3232
expect((await stat(join(cwd, ".amplify-hosting", "static", "assets"))).isDirectory()).toBe(true);
3333
});
3434

35-
test("vite 6 with unstable_viteEnvironmentApi future flag", {timeout: 60_000}, async () => {
35+
test("vite 6 with unstable_viteEnvironmentApi future flag", async () => {
3636
cwd = await createProject({
3737
"react-router.config.ts": reactRouterConfig({
3838
viteEnvironmentApi: true,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { defineProject } from "vitest/config";
2+
import pkg from "./package.json";
3+
4+
export default defineProject({
5+
test: {
6+
name: `${pkg.name}-integration`,
7+
include: ["integration/**/*.test.ts"],
8+
testTimeout: 90_000,
9+
exclude: [
10+
"**/node_modules/**",
11+
"**/dist/**",
12+
],
13+
},
14+
});
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { defineProject } from "vitest/config";
2+
import pkg from "./package.json";
3+
4+
export default defineProject({
5+
test: {
6+
name: `${pkg.name}-unit`,
7+
include: ["**/*.test.ts"],
8+
exclude: ["integration/**"],
9+
},
10+
});

vitest.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineConfig } from "vitest/config";
22

33
export default defineConfig({
44
test: {
5-
workspace: ["packages/*"],
5+
workspace: ["packages/*/vitest.config.{unit,integration}.ts"],
66
coverage: {
77
exclude: [
88
"coverage/**",

0 commit comments

Comments
 (0)