Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: making test-runner-run.mjs ignore colors #54552

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions test/parallel/test-runner-run.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { join } from 'node:path';
import { describe, it, run } from 'node:test';
import { dot, spec, tap } from 'node:test/reporters';
import assert from 'node:assert';
import util from 'node:util';

const testFixtures = fixtures.path('test-runner');

Expand Down Expand Up @@ -68,10 +69,10 @@ describe('require(\'node:test\').run', { concurrency: true }, () => {
const result = await run({
files: [join(testFixtures, 'default-behavior/test/random.cjs')]
}).compose(dot).toArray();
assert.deepStrictEqual(result, [
'.',
'\n',
]);

Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
assert.strictEqual(result.length, 2);

I'm not sure if this is even needed, would there be a case where the length isn't two?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RedYetiDev sure? I can add it, I don't think it is super valuable tho

Copy link
Member

Choose a reason for hiding this comment

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

Whatever you think is best

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@RedYetiDev well, updated 😄

assert.strictEqual(result.length, 2);
assert.strictEqual(util.stripVTControlCharacters(result[0]), '.');
assert.strictEqual(result[1], '\n');
Comment on lines +73 to +75
Copy link
Contributor

@aduh95 aduh95 Sep 6, 2024

Choose a reason for hiding this comment

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

nit: using deepStrictEqual makes for a much better DX if the test was to fail.

Suggested change
assert.strictEqual(result.length, 2);
assert.strictEqual(util.stripVTControlCharacters(result[0]), '.');
assert.strictEqual(result[1], '\n');
assert.deepStrictEqual(
result?.map?.((v, i) => i === 0 ? util.stripVTControlCharacters(v) : v),
['.', '\n'],
);

Copy link
Contributor Author

@puskin94 puskin94 Sep 6, 2024

Choose a reason for hiding this comment

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

@aduh95 I am 👎 on this. For 2 lines a loop is just overkill and introduces complexity and confusion IMHO

});

describe('should be piped with spec reporter', () => {
Expand Down
Loading