Skip to content

Commit cb03a42

Browse files
fixup!: rename failxfail
1 parent 32bff8e commit cb03a42

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

lib/internal/test_runner/harness.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ function runInParentContext(Factory) {
377377

378378
return run(name, options, fn, overrides);
379379
};
380-
ArrayPrototypeForEach(['fail', 'skip', 'todo', 'only'], (keyword) => {
380+
ArrayPrototypeForEach(['xfail', 'skip', 'todo', 'only'], (keyword) => {
381381
test[keyword] = (name, options, fn) => {
382382
const overrides = {
383383
__proto__: null,

lib/internal/test_runner/reporter/tap.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ async function * tapReporter(source) {
3333
for await (const { type, data } of source) {
3434
switch (type) {
3535
case 'test:fail': {
36-
yield reportTest(data.nesting, data.testNumber, 'not ok', data.name, data.fail, data.skip, data.todo);
36+
yield reportTest(data.nesting, data.testNumber, 'not ok', data.name, data.skip, data.todo, data.xfail);
3737
const location = data.file ? `${data.file}:${data.line}:${data.column}` : null;
3838
yield reportDetails(data.nesting, data.details, location);
3939
break;
4040
} case 'test:pass':
41-
yield reportTest(data.nesting, data.testNumber, 'ok', data.name, data.expectFail, data.skip, data.todo);
41+
yield reportTest(data.nesting, data.testNumber, 'ok', data.name, data.skip, data.todo, data.xfail);
4242
yield reportDetails(data.nesting, data.details, null);
4343
break;
4444
case 'test:plan':
@@ -65,22 +65,22 @@ async function * tapReporter(source) {
6565
}
6666
}
6767

68-
function reportTest(nesting, testNumber, status, name, fail, skip, todo) {
68+
function reportTest(nesting, testNumber, status, name, skip, todo, xfail) {
6969
let line = `${indent(nesting)}${status} ${testNumber}`;
7070

7171
if (name) {
7272
line += ` ${tapEscape(`- ${name}`)}`;
7373
}
74-
console.trace('fail:', fail)
74+
7575
if (skip !== undefined) {
7676
line += ` # SKIP${typeof skip === 'string' && skip.length ? ` ${tapEscape(skip)}` : ''}`;
7777
} else if (todo !== undefined) {
7878
line += ` # TODO${typeof todo === 'string' && todo.length ? ` ${tapEscape(todo)}` : ''}`;
7979
}
8080
// `skip` should trump, and `todo` + `fail` is a mistake, but it will already fail, so nothing to
8181
// do when this is after `todo`.
82-
else if (fail !== undefined) {
83-
line += ` # EXPECTED FAIL${typeof fail === 'string' && fail.length ? ` ${tapEscape(fail)}` : ''}`;
82+
else if (xfail !== undefined) {
83+
line += ' # EXPECTED FAIL';
8484
}
8585

8686
line += '\n';

lib/internal/test_runner/test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,6 @@ class TestContext {
351351
this.#test.runOnlySubtests = !!value;
352352
}
353353

354-
fail(err) {
355-
console.log('err:', err);
356-
this.#test.fail(err);
357-
}
358-
359354
skip(message) {
360355
this.#test.skip(message);
361356
}
@@ -512,7 +507,7 @@ class Test extends AsyncResource {
512507
super('Test');
513508

514509
let { fn, name, parent } = options;
515-
const { concurrency, entryFile, fail, loc, only, timeout, todo, skip, signal, plan } = options;
510+
const { concurrency, entryFile, xfail, loc, only, timeout, todo, skip, signal, plan } = options;
516511

517512
if (typeof fn !== 'function') {
518513
fn = noop;
@@ -651,7 +646,7 @@ class Test extends AsyncResource {
651646
this.plan = null;
652647
this.expectedAssertions = plan;
653648
this.cancelled = false;
654-
this.expectFail = fail !== undefined && fail !== false;
649+
this.xfail = xfail !== undefined && xfail !== false;
655650
this.skipped = skip !== undefined && skip !== false;
656651
this.isTodo = (todo !== undefined && todo !== false) || this.parent?.isTodo;
657652
this.startTime = null;
@@ -955,7 +950,7 @@ class Test extends AsyncResource {
955950
return;
956951
}
957952

958-
if (this.expectFail === true) {
953+
if (this.xfail === true) {
959954
this.passed = true;
960955
} else {
961956
this.passed = false;

test/fixtures/test-runner/output/describe_it.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ const { describe, it, test } = require('node:test');
55
const util = require('util');
66

77

8-
it.fail('sync expect to fail', () => {
8+
it.xfail('sync expect fail', () => {
99
throw new Error('should pass');
1010
});
1111

12-
it('sync expect to fail', { fail: true }, () => {
12+
it('sync expect fail', { xfail: true }, () => {
1313
throw new Error('should pass');
1414
});
1515

16-
it.fail('sync expect to fail', async () => {
16+
it.xfail('sync expect fail', async () => {
1717
throw new Error('should pass');
1818
});
1919

20-
it('sync expect to fail', { fail: true }, async () => {
20+
it('sync expect fail', { xfail: true }, async () => {
2121
throw new Error('should pass');
2222
});
2323

@@ -32,7 +32,7 @@ it.todo('sync todo', () => {
3232
throw new Error('should not count as a failure');
3333
});
3434

35-
it.todo('sync todo with expect fail', { fail: true }, () => {
35+
it.todo('sync todo with expect fail', { xfail: true }, () => {
3636
throw new Error('should not count as an expected failure');
3737
});
3838

@@ -43,7 +43,7 @@ it('sync todo with message', { todo: 'this is a failing todo' }, () => {
4343
it.skip('sync skip pass', () => {
4444
});
4545

46-
it.skip('sync skip expect fail', { fail: true }, () => {
46+
it.skip('sync skip expect fail', { xfail: true }, () => {
4747
throw new Error('should not fail');
4848
});
4949

0 commit comments

Comments
 (0)