From 5e953c973f492f3511fa4c0b262f5c9312eb6d0d Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Mar 2026 00:13:42 +0000 Subject: [PATCH 1/3] docs(tasks): add test-script-isolation epic for issue #149 --- lib/exports.test.js | 42 +++++++++++++++++++++++++++++ tasks/test-script-isolation-epic.md | 21 +++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 tasks/test-script-isolation-epic.md diff --git a/lib/exports.test.js b/lib/exports.test.js index e07b10e..8502528 100644 --- a/lib/exports.test.js +++ b/lib/exports.test.js @@ -106,6 +106,48 @@ describe("package.json dependency overrides", () => { }); }); +describe("package.json scripts configuration", () => { + test("npm test excludes e2e tests", async () => { + const pkg = await import("../package.json", { with: { type: "json" } }); + const testScript = pkg.default.scripts.test; + const runsE2e = + !testScript.includes("--exclude") && + !testScript.includes("test:unit") && + !testScript.includes("exclude"); + + assert({ + given: "npm test is invoked", + should: "not run e2e test files", + actual: runsE2e, + expected: false, + }); + }); + + test("npm run test:unit excludes e2e tests", async () => { + const pkg = await import("../package.json", { with: { type: "json" } }); + const testUnitScript = pkg.default.scripts["test:unit"]; + + assert({ + given: "npm run test:unit is invoked", + should: "exclude e2e test files", + actual: testUnitScript.includes("--exclude"), + expected: true, + }); + }); + + test("npm run test:e2e only targets e2e tests", async () => { + const pkg = await import("../package.json", { with: { type: "json" } }); + const testE2eScript = pkg.default.scripts["test:e2e"]; + + assert({ + given: "npm run test:e2e is invoked", + should: "only target e2e test files", + actual: testE2eScript.includes("e2e"), + expected: true, + }); + }); +}); + describe("package.json exports configuration", () => { test("does not include root export", async () => { const pkg = await import("../package.json", { with: { type: "json" } }); diff --git a/tasks/test-script-isolation-epic.md b/tasks/test-script-isolation-epic.md new file mode 100644 index 0000000..6c30f34 --- /dev/null +++ b/tasks/test-script-isolation-epic.md @@ -0,0 +1,21 @@ +# Test Script Isolation Epic + +**Status**: 🔄 IN PROGRESS +**Goal**: Ensure `npm test` only runs unit tests and lint — never e2e tests. + +## Problem + +`npm test` currently runs `vitest run` without any exclusion filters, which causes +e2e tests to be included alongside unit tests. E2e tests have side-effects, depend +on external processes, and can be slow — making them unsuitable to run as part of +the default `npm test` command. + +## Requirements + +- Given `npm test` is invoked, should only run unit tests and lint (not e2e tests) +- Given `npm run test:unit` is invoked, should only run unit tests and lint (not e2e tests) +- Given `npm run test:e2e` is invoked, should only run e2e tests + +## References + +- [Issue #149](https://github.com/paralleldrive/aidd/issues/149) From 23d7401be75d1cf9d1d5272a94b9b450c6edde2e Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Mar 2026 00:13:54 +0000 Subject: [PATCH 2/3] fix(scripts): npm test no longer runs e2e tests Delegates 'test' to 'test:unit' which excludes '*-e2e.test.js' files. E2e tests continue to run via 'npm run test:e2e'. Closes #149 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9c1068a..0dfdb62 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "lint": "npx @biomejs/biome check --write && echo 'Lint fix complete.'", "prepare": "husky", "release": "node release.js", - "test": "vitest run && echo 'Test complete.' && npm run -s lint && npm run -s typecheck", + "test": "npm run test:unit", "test:e2e": "vitest run **/*-e2e.test.js && echo 'E2E tests complete.'", "test:unit": "vitest run --exclude '**/*-e2e.test.js' && echo 'Unit tests complete.' && npm run -s lint && npm run -s typecheck", "toc": "doctoc README.md", From d72bcb9534f1f1645f488b0e45415ff1deb71fba Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sat, 14 Mar 2026 00:23:48 +0000 Subject: [PATCH 3/3] revert: undo npm test isolation change The test:unit script already provided the isolation users need. npm test running all tests (including e2e) was the original intent. --- lib/exports.test.js | 42 ----------------------------- package.json | 2 +- tasks/test-script-isolation-epic.md | 21 --------------- 3 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 tasks/test-script-isolation-epic.md diff --git a/lib/exports.test.js b/lib/exports.test.js index 8502528..e07b10e 100644 --- a/lib/exports.test.js +++ b/lib/exports.test.js @@ -106,48 +106,6 @@ describe("package.json dependency overrides", () => { }); }); -describe("package.json scripts configuration", () => { - test("npm test excludes e2e tests", async () => { - const pkg = await import("../package.json", { with: { type: "json" } }); - const testScript = pkg.default.scripts.test; - const runsE2e = - !testScript.includes("--exclude") && - !testScript.includes("test:unit") && - !testScript.includes("exclude"); - - assert({ - given: "npm test is invoked", - should: "not run e2e test files", - actual: runsE2e, - expected: false, - }); - }); - - test("npm run test:unit excludes e2e tests", async () => { - const pkg = await import("../package.json", { with: { type: "json" } }); - const testUnitScript = pkg.default.scripts["test:unit"]; - - assert({ - given: "npm run test:unit is invoked", - should: "exclude e2e test files", - actual: testUnitScript.includes("--exclude"), - expected: true, - }); - }); - - test("npm run test:e2e only targets e2e tests", async () => { - const pkg = await import("../package.json", { with: { type: "json" } }); - const testE2eScript = pkg.default.scripts["test:e2e"]; - - assert({ - given: "npm run test:e2e is invoked", - should: "only target e2e test files", - actual: testE2eScript.includes("e2e"), - expected: true, - }); - }); -}); - describe("package.json exports configuration", () => { test("does not include root export", async () => { const pkg = await import("../package.json", { with: { type: "json" } }); diff --git a/package.json b/package.json index 0dfdb62..9c1068a 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "lint": "npx @biomejs/biome check --write && echo 'Lint fix complete.'", "prepare": "husky", "release": "node release.js", - "test": "npm run test:unit", + "test": "vitest run && echo 'Test complete.' && npm run -s lint && npm run -s typecheck", "test:e2e": "vitest run **/*-e2e.test.js && echo 'E2E tests complete.'", "test:unit": "vitest run --exclude '**/*-e2e.test.js' && echo 'Unit tests complete.' && npm run -s lint && npm run -s typecheck", "toc": "doctoc README.md", diff --git a/tasks/test-script-isolation-epic.md b/tasks/test-script-isolation-epic.md deleted file mode 100644 index 6c30f34..0000000 --- a/tasks/test-script-isolation-epic.md +++ /dev/null @@ -1,21 +0,0 @@ -# Test Script Isolation Epic - -**Status**: 🔄 IN PROGRESS -**Goal**: Ensure `npm test` only runs unit tests and lint — never e2e tests. - -## Problem - -`npm test` currently runs `vitest run` without any exclusion filters, which causes -e2e tests to be included alongside unit tests. E2e tests have side-effects, depend -on external processes, and can be slow — making them unsuitable to run as part of -the default `npm test` command. - -## Requirements - -- Given `npm test` is invoked, should only run unit tests and lint (not e2e tests) -- Given `npm run test:unit` is invoked, should only run unit tests and lint (not e2e tests) -- Given `npm run test:e2e` is invoked, should only run e2e tests - -## References - -- [Issue #149](https://github.com/paralleldrive/aidd/issues/149)