Skip to content

Finalize “test” interface (adds “options”).#115

Merged
theengineear merged 1 commit into
mainfrom
finalize-test-interface
May 4, 2026
Merged

Finalize “test” interface (adds “options”).#115
theengineear merged 1 commit into
mainfrom
finalize-test-interface

Conversation

@theengineear
Copy link
Copy Markdown
Collaborator

We aim to be a strict subset of what node:test offers — no real reason to diverge there. As such, rather than take interval as an optional, positional argument, we should match Node’s options interface which allows for { timeout?: number } to be defined.

We aim to be a _strict subset_ of what `node:test` offers — no real
reason to diverge there. As such, rather than take `interval` as an
optional, positional argument, we should match Node’s _options_
interface which allows for `{ timeout?: number }` to be defined.
Comment thread x-test.js
* @returns {void}
*/
export function test(name, fn, timeout) {
export function test(name, options, fn) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is the way. The tradeoff is between positional arguments (which we typically favor) and matching a well-known JS interface (Node’s standard test runner). In this case, the pragmatic / responsible choice is to mirror the prior art.

Comment thread x-test.js
}

/**
* @overload
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Because of the new call-signature, we need to do this over-loading thing to make all the tooling understand. Still, a small cost to pay for parity. At the end of the day, doing this means we can claim that any test written in x-test is a valid node test.

@theengineear theengineear merged commit 55c3944 into main May 4, 2026
1 check passed
@theengineear theengineear deleted the finalize-test-interface branch May 4, 2026 04:24
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.

1 participant