Migrate from Jest to node:test #115

Merged
schmelczer merged 2 commits from asch/node-tests into main 2025-08-30 10:38:09 +01:00
schmelczer commented 2025-08-30 09:59:45 +01:00 (Migrated from github.com)

There's no reason to use Jest as https://nodejs.org/api/test.html#test-runner is a modern alternative to do TS testing

There's no reason to use Jest as https://nodejs.org/api/test.html#test-runner is a modern alternative to do TS testing
copilot-pull-request-reviewer[bot] (Migrated from github.com) reviewed 2025-08-30 10:00:28 +01:00
copilot-pull-request-reviewer[bot] (Migrated from github.com) left a comment

Pull Request Overview

This PR migrates the test framework from Jest to Node.js's built-in test runner (node:test). The migration replaces Jest-specific assertions and mocking APIs with their Node.js equivalents across all test files in the frontend packages.

Key changes:

  • Replace Jest test runner with tsx --test command for running TypeScript tests
  • Update all test files to use node:test imports and node:assert assertions
  • Remove Jest configuration files and dependencies

Reviewed Changes

Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
scripts/check.sh Reorders test execution before linting in the frontend check sequence
frontend/test-client/tsconfig.json Updates TypeScript lib target from "ESNext" to "ES2024"
frontend/test-client/src/utils/random-casing.test.ts Migrates from Jest assertions to node:assert with describe/it imports
frontend/test-client/package.json Replaces Jest with tsx test runner and removes Jest dependencies
frontend/test-client/jest.config.js Removes Jest configuration file
frontend/sync-client/tsconfig.json Adds "ES2024" to lib array for modern JavaScript features
frontend/sync-client/src/utils/rate-limit.test.ts Converts Jest mocks and timers to node:test equivalents
frontend/sync-client/src/utils/min-covered.test.ts Replaces Jest test syntax with node:test describe/it structure
frontend/sync-client/src/utils/locks.test.ts Updates assertions from Jest expect to node:assert methods
frontend/sync-client/src/utils/is-file-type-mergable.test.ts Migrates test assertions to node:assert with improved formatting
frontend/sync-client/src/utils/is-equal-bytes.test.ts Converts Jest assertions to node:assert equivalents
frontend/sync-client/src/utils/globs-to-regexes.test.ts Updates truthiness assertions to use assert.ok
frontend/sync-client/src/utils/assert-set-contains-exactly.ts Changes assert import to use node:assert and assert.ok method
frontend/sync-client/src/sync-client.ts Adds offline sync state tracking with hasStartedOfflineSync flag
frontend/sync-client/src/services/sync-service.ts Wraps contentBytes in Uint8Array for Blob constructor compatibility
frontend/sync-client/src/file-operations/file-operations.test.ts Adds node:test imports to test file
frontend/sync-client/package.json Updates test script and removes Jest dependencies, adds tsx
frontend/sync-client/jest.config.js Removes Jest configuration file
frontend/obsidian-plugin/tsconfig.json Updates lib target from "ESNext" to "ES2024"
frontend/obsidian-plugin/src/utils/position-to-line-and-column.test.ts Migrates test structure and assertions to node:test framework
frontend/obsidian-plugin/src/utils/line-and-column-to-position.test.ts Converts Jest tests to node:test with assert methods
frontend/obsidian-plugin/package.json Replaces Jest with tsx test runner and reorders dependencies
frontend/obsidian-plugin/jest.config.js Removes Jest configuration file
frontend/eslint.config.mjs Updates ESLint config to allow node:test functions in no-floating-promises rule

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

## Pull Request Overview This PR migrates the test framework from Jest to Node.js's built-in test runner (`node:test`). The migration replaces Jest-specific assertions and mocking APIs with their Node.js equivalents across all test files in the frontend packages. Key changes: - Replace Jest test runner with `tsx --test` command for running TypeScript tests - Update all test files to use `node:test` imports and `node:assert` assertions - Remove Jest configuration files and dependencies ### Reviewed Changes Copilot reviewed 24 out of 25 changed files in this pull request and generated 2 comments. <details> <summary>Show a summary per file</summary> | File | Description | | ---- | ----------- | | scripts/check.sh | Reorders test execution before linting in the frontend check sequence | | frontend/test-client/tsconfig.json | Updates TypeScript lib target from "ESNext" to "ES2024" | | frontend/test-client/src/utils/random-casing.test.ts | Migrates from Jest assertions to node:assert with describe/it imports | | frontend/test-client/package.json | Replaces Jest with tsx test runner and removes Jest dependencies | | frontend/test-client/jest.config.js | Removes Jest configuration file | | frontend/sync-client/tsconfig.json | Adds "ES2024" to lib array for modern JavaScript features | | frontend/sync-client/src/utils/rate-limit.test.ts | Converts Jest mocks and timers to node:test equivalents | | frontend/sync-client/src/utils/min-covered.test.ts | Replaces Jest test syntax with node:test describe/it structure | | frontend/sync-client/src/utils/locks.test.ts | Updates assertions from Jest expect to node:assert methods | | frontend/sync-client/src/utils/is-file-type-mergable.test.ts | Migrates test assertions to node:assert with improved formatting | | frontend/sync-client/src/utils/is-equal-bytes.test.ts | Converts Jest assertions to node:assert equivalents | | frontend/sync-client/src/utils/globs-to-regexes.test.ts | Updates truthiness assertions to use assert.ok | | frontend/sync-client/src/utils/assert-set-contains-exactly.ts | Changes assert import to use node:assert and assert.ok method | | frontend/sync-client/src/sync-client.ts | Adds offline sync state tracking with hasStartedOfflineSync flag | | frontend/sync-client/src/services/sync-service.ts | Wraps contentBytes in Uint8Array for Blob constructor compatibility | | frontend/sync-client/src/file-operations/file-operations.test.ts | Adds node:test imports to test file | | frontend/sync-client/package.json | Updates test script and removes Jest dependencies, adds tsx | | frontend/sync-client/jest.config.js | Removes Jest configuration file | | frontend/obsidian-plugin/tsconfig.json | Updates lib target from "ESNext" to "ES2024" | | frontend/obsidian-plugin/src/utils/position-to-line-and-column.test.ts | Migrates test structure and assertions to node:test framework | | frontend/obsidian-plugin/src/utils/line-and-column-to-position.test.ts | Converts Jest tests to node:test with assert methods | | frontend/obsidian-plugin/package.json | Replaces Jest with tsx test runner and reorders dependencies | | frontend/obsidian-plugin/jest.config.js | Removes Jest configuration file | | frontend/eslint.config.mjs | Updates ESLint config to allow node:test functions in no-floating-promises rule | </details> --- <sub>**Tip:** Customize your code reviews with copilot-instructions.md. <a href="/schmelczer/vault-link/new/main/.github?filename=copilot-instructions.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Create the file</a> or <a href="https://docs.github.com/en/copilot/customizing-copilot/adding-repository-custom-instructions-for-github-copilot" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">learn how to get started</a>.</sub>
@ -74,0 +73,4 @@
formData.append(
"content",
new Blob([new Uint8Array(contentBytes)])
);
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-30 10:00:28 +01:00

The new Uint8Array(contentBytes) wrapper appears unnecessary if contentBytes is already a Uint8Array or compatible type. Consider checking if this conversion is actually needed, as it may create an unnecessary copy of the data.

				new Blob([contentBytes])
The `new Uint8Array(contentBytes)` wrapper appears unnecessary if `contentBytes` is already a Uint8Array or compatible type. Consider checking if this conversion is actually needed, as it may create an unnecessary copy of the data. ```suggestion new Blob([contentBytes]) ```
@ -25,3 +25,4 @@
export class SyncClient {
private static readonly MINIMUM_SAVE_INTERVAL_MS = 1000;
private hasStartedOfflineSync = false;
private hasFinishedOfflineSync = false;
copilot-pull-request-reviewer[bot] (Migrated from github.com) commented 2025-08-30 10:00:27 +01:00

[nitpick] The new hasStartedOfflineSync property should be declared before hasFinishedOfflineSync to maintain logical ordering, as the start operation precedes the finish operation.

[nitpick] The new `hasStartedOfflineSync` property should be declared before `hasFinishedOfflineSync` to maintain logical ordering, as the start operation precedes the finish operation.
Sign in to join this conversation.
No description provided.