Skip to content

Add eslint-node-test and export nodeTest config - #141

Draft
risantos wants to merge 4 commits into
masterfrom
feature/node-test
Draft

risantos wants to merge 4 commits into
masterfrom
feature/node-test

Conversation

@risantos

Copy link
Copy Markdown
Member

Description

  • Added a new nodeTest ESLint config for the Node.js built-in test runner (node:test), usingeslint-node-test as a peer dependency, and custom rules to accomodate it
  • Modernized tests in test/index.test.js to use TestContext assertions and snapshot testing instead of assert, applying the newly exported rules.
  • Added new scripts for updating test snapshots and watching tests with the Node.js test runner. (test:snapshot, test:watch)
  • Simplified and standardized dynamic plugin loading types in framework configs.

@risantos
risantos force-pushed the feature/node-test branch from a9ba258 to 200b0c5 Compare July 14, 2026 18:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds first-class support for Node.js’s built-in test runner (node:test) by introducing a new nodeTest ESLint config (powered by eslint-node-test), and modernizes the repository’s test suite to use node:test’s TestContext assertions and snapshot testing.

Changes:

  • Added src/configs/nodetest.js, exported as nodeTest, and documented it in the README.
  • Migrated tests from node:assert to TestContext assertions and introduced/updated snapshot files.
  • Standardized dynamic plugin loading typings and updated test runner scripts (including snapshot update/watch helpers).

Reviewed changes

Copilot reviewed 34 out of 35 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
yarn.lock Adds lock entries for eslint-node-test and quote-js-string.
test/src/utils/load-module.test.js Migrates assertions to TestContext (t.assert.*).
test/src/rules/require-comment-punctuation.test.js Converts tests to accept TestContext and uses t.assert (includes a no-op assertion).
test/src/rules/no-trailing-period-in-log-messages.test.js Converts tests to accept TestContext and uses t.assert (includes a no-op assertion).
test/src/rules/index.test.js.snapshot New snapshot for exported rules metadata.
test/src/rules/index.test.js Switches “exported rules” test to snapshot-based assertion.
test/src/rules/database-migration-filename-format/index.test.js.snapshot New snapshots for migration filename rule results.
test/src/rules/database-migration-filename-format/index.test.js Migrates to TestContext assertions and snapshots for lint results.
test/src/configs/vitest.test.js.snapshot New snapshots for Vitest config factory outputs.
test/src/configs/vitest.test.js Migrates to TestContext assertions and snapshots.
test/src/configs/typescript.test.js.snapshot New/updated snapshots for TypeScript config factory outputs.
test/src/configs/typescript.test.js Migrates to TestContext assertions and adds snapshots; some assertions were replaced.
test/src/configs/nodetest.test.js.snapshot New snapshots for Node test config factory outputs.
test/src/configs/nodetest.test.js New tests covering createNodeTestConfig() behaviors.
test/src/configs/mocha.test.js.snapshot New snapshots for Mocha config factory outputs.
test/src/configs/mocha.test.js Migrates to TestContext assertions and snapshots.
test/src/configs/jest.test.js.snapshot New snapshots for Jest config factory outputs.
test/src/configs/jest.test.js Migrates to TestContext assertions and snapshots.
test/src/configs/javascript.test.js.snapshot New snapshots for JavaScript config factory outputs.
test/src/configs/javascript.test.js Migrates to TestContext assertions and snapshots.
test/src/configs/index.test.js.snapshot New snapshot for config exports list (now includes nodeTest).
test/src/configs/index.test.js Updates exports tests to include nodeTest and uses snapshots/TestContext.
test/index.test.js.snapshot New snapshots for root exports and lint violation list.
test/index.test.js Migrates to TestContext assertions and snapshots; updates exports test to include nodeTest.
src/utils/load-module.js Updates dynamic import typing map for standardized “default vs module namespace” handling.
src/index.js Re-exports nodeTest from src/configs/index.js.
src/configs/vitest.js Simplifies dynamic plugin load typing and aligns loader util typing.
src/configs/typescript.js Simplifies dynamic plugin load typing and aligns loader util typing.
src/configs/nodetest.js Introduces new createNodeTestConfig() config factory using eslint-node-test.
src/configs/mocha.js Simplifies dynamic plugin load typing and aligns loader util typing.
src/configs/jest.js Simplifies dynamic plugin load typing and aligns loader util typing.
src/configs/index.js Exports nodeTest config via top-level await factory invocation.
README.md Documents the new nodeTest config and updates import examples.
package.json Adds eslint-node-test (dev + optional peer), and adds test runner scripts for snapshots/watch.
eslint.config.js Extends nodeTest config for repo tests and disables node-test/require-assertion in tests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/configs/nodetest.js
Comment on lines +10 to +12
* @param {object} [utils] - Optional utilities for dependency injection (for testing).
* @param {(moduleName: string) => boolean} utils.isModuleAvailable - Check if a module is available.
* @param {typeof loadModule} [utils.loadModule] - Dynamically load a module.
Comment thread src/configs/nodetest.js
Comment on lines +45 to +48
process.emitWarning('`eslint-node-test` is not installed, Node test linting will be disabled', {
code: 'UPHOLD_ESLINT_NODE_TEST_PLUGIN_MISSING',
type: 'UpholdEslintWarning'
});
Comment thread src/configs/nodetest.js
Comment on lines +50 to +52
return defineConfig({
name: 'uphold/empty-nodeTest'
});
Comment on lines +262 to 263
t.assert.snapshot(config[0]);
});
'no-trailing-period-in-log-messages',
'require-comment-punctuation'
]);
assert.snapshot(Object.entries(rules));
Comment thread README.md

- [Jest](https://jestjs.io/), depending on `eslint-plugin-jest`.
- [Mocha](https://mochajs.org/), depending on `eslint-plugin-mocha`.
- [Node.js built-in test runner (`node:test`)](https://nodejs.org/api/test.html), depending on `eslint-node-test`
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