Skip to content

Migrate tests to node:test and update CI#273

Open
cubap wants to merge 7 commits into
mainfrom
testing-testing
Open

Migrate tests to node:test and update CI#273
cubap wants to merge 7 commits into
mainfrom
testing-testing

Conversation

@cubap
Copy link
Copy Markdown
Member

@cubap cubap commented May 13, 2026

Replace Jest-based test setup with native node:test/assert and update CI. Tests were refactored to use node:test and node:assert (many tests/* updated), new auth token unit tests added, and routes_mounted.test.js reworked to a data-driven style. The database mock was rewritten to remove Jest-specific APIs and provide a lightweight mock/registry with resetMocks; jest.config.js was removed. GitHub Actions workflows now separate install, test (npm run test:ci) and coverage (npm run coverage:ci) steps. package.json dev tooling and test scripts were adjusted accordingly, and test bootstrap/loader/coverage artifacts were added while placeholder .txt test files were removed.

Replace Jest-based test setup with native node:test/assert and update CI. Tests were refactored to use node:test and node:assert (many __tests__ updated), new auth token unit tests added, and routes_mounted.test.js reworked to a data-driven style. The database mock was rewritten to remove Jest-specific APIs and provide a lightweight mock/registry with resetMocks; jest.config.js was removed. GitHub Actions workflows now separate install, test (npm run test:ci) and coverage (npm run coverage:ci) steps. package.json dev tooling and test scripts were adjusted accordingly, and test bootstrap/loader/coverage artifacts were added while placeholder .txt test files were removed.
@cubap cubap requested a review from thehabes as a code owner May 13, 2026 21:00
@cubap cubap requested a review from Copilot May 13, 2026 21:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Migrates the test harness from Jest to the native node:test / node:assert runner. The custom database/__mocks__/index.js now ships its own minimal mock-function factory (with resetMocks()), a small loader/bootstrap pair redirects production database/index.js imports to the mock, and Jest-specific config, dependencies, and globals are removed. CI is split into separate install / test / coverage steps using c8, and several dotenv.config() calls are dropped in favor of node --env-file-if-exists=.env. New native tests are added for auth helpers and overwrite optimistic locking, and routes_mounted.test.js and content-type tests are restructured into data-driven loops.

Changes:

  • Replace Jest globals/expect across all __tests__ files with node:test + node:assert/strict, and rewrite the database mock to expose Jest-compatible mock* helpers without depending on Jest.
  • Update package.json scripts, drop jest/@jest/globals/dotenv dev deps, add c8, and update cd_dev.yaml / cd_prod.yaml to run test:ci and coverage:ci separately.
  • Add auth/__tests__/token.test.js and routes/__tests__/overwrite.test.js, delete placeholder .txt files, and add test/bootstrap.js, test/loader.js, and test/coverage-inventory.json.

Reviewed changes

Copilot reviewed 37 out of 40 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
package.json Switches scripts to node --test + c8, drops Jest/dotenv deps, adds c8.
jest.config.js Removed (Jest no longer used).
test/bootstrap.js, test/loader.js New ESM loader hook that redirects database/index.js to the mock for tests.
test/coverage-inventory.json Hand-maintained snapshot of suites, coverage, and harness changes.
database/__mocks__/index.js Rewritten as a Jest-free mock with resetMocks() and additional db.updateOne/findOneAndUpdate stubs.
database/index.js, app.js, bin/rerum_v1.js, auth/index.js Drop runtime dotenv.config() calls (now handled by --env-file-if-exists).
auth/__tests__/token.test.js (+ removed .txt) New unit tests for READONLY, isBot, isGenerator, and generateNewAccessToken.
routes/__tests__/*.test.js Migrated CRUD/route tests to node:test, added beforeEach(resetMocks).
routes/__tests__/overwrite.test.js (+ removed .txt versions) New optimistic-locking tests for /overwrite and version header on /id.
routes/__tests__/bulkUpdate.test.js Replaces skipped TODO with a real mocked test.
routes/__tests__/contentType.test.js, __tests__/routes_mounted.test.js Refactored into data-driven loops.
__tests__/core_provider_contract.test.js, __tests__/openapi_sync_artifacts.test.js, __tests__/provider_sync_artifacts.test.js Migrated assertions to assert.match / assert.deepEqual.
.github/workflows/cd_dev.yaml, .github/workflows/cd_prod.yaml Split into install / test:ci / coverage:ci steps.
Removed .txt placeholder tests Cleanup of deprecated stubs.

Comment thread .github/workflows/cd_dev.yaml Outdated
Comment thread database/__mocks__/index.js
Comment thread test/coverage-inventory.json Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants