test_runner,cli: --test-timeout should be used with --test#53773
test_runner,cli: --test-timeout should be used with --test#53773jakecastelli wants to merge 1 commit intonodejs:mainfrom
Conversation
|
Review requested:
|
24f9ad9 to
fe8cc89
Compare
|
Isn't it breaking change? (nobody should use test timeout without test but it would break now) |
|
Hi @rluvaton, yes it would break, on the other hand this feels more like a bug or at least false positive to me. As without |
|
I don't think this is the correct fix. The problem is that |
|
Hi @cjihrig thanks for your input, I thought the origin implementation meant to be used with
Now I see your point, in that case we will need to grab the Let me know your thoughts, cheers. |
|
I have another question which is when consider the following code snippet: import { test } from "node:test";
test("test timeout", { timeout: 100 }, (t, done) => {
setTimeout(done, 3000);
});node --test-timeout=2000Should |
|
I tend to lean to Test timeout > cli flag > run config |
I think local config should take precedence over more global config. In other words test timeout > |
cjihrig
left a comment
There was a problem hiding this comment.
Explicitly requesting changes. This is technically a breaking change. If we are going to introduce a breaking change on this flag, we should do so in a way that actually makes it better.
Could you explain in which area we could make it better? My understanding is that:
Anything else I could've missed? |
|
Let me try to explain with an example. Consider the following file named 'use strict';
const { test } = require('node:test');
test('delay', () => {
return new Promise((resolve) => {
setTimeout(resolve, 10_000);
});
});
test('pass');Someone could run this in a few ways relevant to this PR:
I am proposing that the behavior of the first two cases stay the same, while the final two cases should both run to completion (the |
|
Oh I see what you mean!! Thanks for explaining it in great details. I agree, the current implementation of |
Hi Colin,
Consider the following example: // test-1.mjs
import { test } from "node:test";
test("test timeout", () => {
return new Promise((resolve) => {
setTimeout(resolve, 5_000);
});
});// test-2.mjs
"use strict";
import { test } from "node:test";
test("delay 10s", () => {
return new Promise((resolve) => {
setTimeout(resolve, 10_000);
});
});
test("delay 1s", () => {
return new Promise((resolve) => {
setTimeout(resolve, 1_000);
});
});
test("pass");when we run As you can see, test cases |
|
@jakecastelli yes, that is the same as the fourth case I mentioned above. If you're interested in working on this, I would suggest starting with the third case above and then working backward from there to the CLI parts (which will be significantly simpler to fix). |
|
Thanks Colin, yes I am interested in working on this and I think I may close to get a draft PR up for feedback soon. |
|
Sorry folks, to clarify, what did you end up doing related to this timeout problem? |
When
--test-timeoutused without--testit does not behave what the user would expect.Refs: #50431 (comment)