Version
18.15.0 (also affects the userland "test" module in 16.16)
Platform
Darwin J1.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
Subsystem
test_harness
What steps will reproduce the bug?
const { describe, it } = require('node:test');
const assert = require('assert');
describe('thing', () => {
it('subthing', async (t) => {
// always throws "passed a callback but also returned a Promise"
assert(true);
});
});
CodeSandbox Demo
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
I expect the test to run.
What do you see instead?
If you remove the t argument, the test works, but with t present the test always throws with ERR_TEST_FAILURE and a message of passed a callback but also returned a Promise.
TAP version 13
# Subtest: thing
# Subtest: subthing
not ok 1 - subthing
---
duration_ms: 0.248708
failureType: 'callbackAndPromisePresent'
error: 'passed a callback but also returned a Promise'
code: 'ERR_TEST_FAILURE'
stack: |-
new Promise (<anonymous>)
Array.map (<anonymous>)
new Promise (<anonymous>)
...
1..1
not ok 1 - thing
---
duration_ms: 1.341708
failureType: 'subtestsFailed'
error: '1 subtest failed'
code: 'ERR_TEST_FAILURE'
...
Additional information
I think this might be an off by one error? If I remove the - 1 from this line, the test works as expected.
Version
18.15.0 (also affects the userland "test" module in 16.16)
Platform
Darwin J1.local 22.3.0 Darwin Kernel Version 22.3.0: Mon Jan 30 20:38:37 PST 2023; root:xnu-8792.81.3~2/RELEASE_ARM64_T6000 arm64
Subsystem
test_harness
What steps will reproduce the bug?
CodeSandbox Demo
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior?
I expect the test to run.
What do you see instead?
If you remove the
targument, the test works, but withtpresent the test always throws withERR_TEST_FAILUREand a message ofpassed a callback but also returned a Promise.Additional information
I think this might be an off by one error? If I remove the
- 1from this line, the test works as expected.