Migrate tests to node:test and update CI#273
Conversation
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.
There was a problem hiding this comment.
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 withnode:test+node:assert/strict, and rewrite the database mock to expose Jest-compatiblemock*helpers without depending on Jest. - Update
package.jsonscripts, dropjest/@jest/globals/dotenvdev deps, addc8, and updatecd_dev.yaml/cd_prod.yamlto runtest:ciandcoverage:ciseparately. - Add
auth/__tests__/token.test.jsandroutes/__tests__/overwrite.test.js, delete placeholder.txtfiles, and addtest/bootstrap.js,test/loader.js, andtest/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. |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.