diff --git a/.vscode/settings.json b/.vscode/settings.json index f8c0f26a..4fac44a6 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -25,7 +25,7 @@ "editor.formatOnSaveMode": "file", "editor.defaultFormatter": "esbenp.prettier-vscode", "jest.rootPath": "packages/foam-vscode", - "jest.jestCommandLine": "yarn test:unit-with-specs", + "jest.jestCommandLine": "yarn test:unit", "gitdoc.enabled": false, "search.mode": "reuseEditor", "[typescript]": { diff --git a/CLAUDE.md b/CLAUDE.md index ab3cb43b..009ed0da 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -25,7 +25,7 @@ All the following commands are to be executed from the `packages/foam-vscode` di ### Testing - `yarn test` - Run all tests (unit + integration) -- `yarn test:unit-with-specs` - Run only unit tests (\*.test.ts files and the .spec.ts files marked a vscode-mock friendly) +- `yarn test:unit` - Run unit tests (\*.test.ts files and the .spec.ts files marked a vscode-mock friendly) - `yarn test:e2e` - Run only integration tests (\*.spec.ts files) - `yarn lint` - Run linting - `yarn test-reset-workspace` to clean test workspace @@ -37,11 +37,10 @@ When running tests, do not provide additional parameters, they are ignored by th Unit tests are named `*.test.ts` and integration tests are `*.spec.ts`. These test files live alongside the code in the `src` directory. An integration test is one that has a direct or indirect dependency on `vscode` module. There is a mock `vscode` module that can be used to run most integration tests without starting VS Code. Tests that can use this mock are start with the line `/* @unit-ready */`. -- If you are interested in a test inside a `*.test.ts` file, run `yarn test:unit` -- If you are interested in a test inside a `*.spec.ts` file that starts with `/* @unit-ready */` run `yarn test:unit-with-specs` +- If you are interested in a test inside a `*.test.ts` file, run `yarn test:unit` or inside a `*.spec.ts` file that starts with `/* @unit-ready */` run `yarn test:unit` - If you are interested in a test inside a `*.spec.ts` file that does not include `/* @unit-ready */` run `yarn test` -While in development we mostly want to use `yarn test:unit-with-specs`. +While in development we mostly want to use `yarn test:unit`. When multiple tests are failing, look at all of them, but only focus on fixing the first one. Once that is fixed, run the test suite again and repeat the process. When writing tests keep mocking to a bare minimum. Code should be written in a way that is easily testable and if I/O is necessary, it should be done in appropriate temporary directories. diff --git a/docs/dev/testing.md b/docs/dev/testing.md index 7940eac1..6e4c048d 100644 --- a/docs/dev/testing.md +++ b/docs/dev/testing.md @@ -49,8 +49,8 @@ This dual-environment capability allows us to: ### Available Commands -- **`yarn test:unit`**: Runs only `.test.ts` files (no VS Code dependencies) -- **`yarn test:unit-with-specs`**: Runs `.test.ts` + `@unit-ready` marked `.spec.ts` files using mocks +- **`yarn test:unit`**: Runs `.test.ts` files (no VS Code dependencies) + `@unit-ready` marked `.spec.ts` files using mocks +- **`yarn test:unit-without-specs`**: Runs only `.test.ts` files - **`yarn test:e2e`**: Runs all `.spec.ts` files in full VS Code extension host - **`yarn test`**: Runs both unit and e2e test suites sequentially diff --git a/package.json b/package.json index eb3e1b93..aec4501e 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "clean": "lerna run clean", "build": "lerna run build", "test": "yarn workspace foam-vscode test", + "test:unit": "yarn workspace foam-vscode test:unit", "lint": "lerna run lint", "watch": "lerna run watch --concurrency 20" }, diff --git a/packages/foam-vscode/package.json b/packages/foam-vscode/package.json index 2095f11a..e9cae08d 100644 --- a/packages/foam-vscode/package.json +++ b/packages/foam-vscode/package.json @@ -711,8 +711,8 @@ "test-reset-workspace": "rm -rf .test-workspace && mkdir .test-workspace && touch .test-workspace/.keep", "test-setup": "yarn compile && yarn build && yarn test-reset-workspace", "test": "yarn test-setup && node ./out/test/run-tests.js", - "test:unit": "yarn test-setup && node ./out/test/run-tests.js --unit --exclude-specs", - "test:unit-with-specs": "yarn test-setup && node ./out/test/run-tests.js --unit", + "test:unit": "yarn test-setup && node ./out/test/run-tests.js --unit", + "test:unit-without-specs": "yarn test-setup && node ./out/test/run-tests.js --unit --exclude-specs", "test:e2e": "yarn test-setup && node ./out/test/run-tests.js --e2e", "lint": "dts lint src", "clean": "rimraf out",