Skip to content

Commit 8636f9d

Browse files
test: replace assert.ok(regex.test()) with assert.match()
1 parent b011cc5 commit 8636f9d

File tree

6 files changed

+12
-7
lines changed

6 files changed

+12
-7
lines changed

test/common/benchmark.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ function runBenchmark(name, env) {
4242

4343
for (let testIdx = 1; testIdx < splitTests.length - 1; testIdx++) {
4444
const lines = splitTests[testIdx].split('\n');
45-
assert.ok(/.+/.test(lines[0]));
46-
45+
assert.match(lines[0], /.+/);
4746
if (!lines[1].includes('group="')) {
4847
assert.strictEqual(lines.length, 2, `benchmark file not running exactly one configuration in test: ${stdout}`);
4948
}

test/js-native-api/test_general/testV8Instanceof2.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@ function InstanceTest(x, func) {
304304
const answer = addon.doInstanceOf(x, func);
305305
assert.strictEqual(correct_answers[correct_answer_index], answer);
306306
} catch (e) {
307-
assert.ok(/prototype/.test(e));
307+
assert.match(e, /prototype/);
308308
assert.strictEqual(correct_answers[correct_answer_index], except);
309309
}
310310
correct_answer_index++;

test/parallel/test-dns-resolver-max-timeout.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const dgram = require('dgram');
2121
try {
2222
new dns.Resolver({ maxTimeout });
2323
} catch (e) {
24-
assert.ok(/ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i.test(e.code));
24+
assert.match(e.code, /ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i);
2525
}
2626
});
2727

test/parallel/test-http2-https-fallback.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ function onSession(session, next) {
165165
.setEncoding('utf8')
166166
.on('data', (chunk) => text += chunk)
167167
.on('end', common.mustCall(() => {
168-
assert.ok(/Missing ALPN Protocol, expected `h2` to be available/.test(text));
168+
assert.match(
169+
text,
170+
/Missing ALPN Protocol, expected `h2` to be available/
171+
);
169172
cleanup();
170173
}));
171174
}

test/parallel/test-runner-mock-timers-date.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ describe('Mock Timers Date Test Suite', () => {
6262
const returned = Date();
6363
// Matches the format: 'Mon Jan 01 1970 00:00:00'
6464
// We don't care about the date, just the format
65-
assert.ok(/\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/.test(returned));
65+
assert.match(
66+
returned,
67+
/\w{3}\s\w{3}\s\d{1,2}\s\d{2,4}\s\d{1,2}:\d{2}:\d{2}/
68+
);
6669
});
6770

6871
it('should return the date with different argument calls', (t) => {

test/parallel/test-worker-cpu-usage.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function check(worker) {
3333
try {
3434
worker.cpuUsage(value);
3535
} catch (e) {
36-
assert.ok(/ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i.test(e.code));
36+
assert.match(e.code, /ERR_OUT_OF_RANGE|ERR_INVALID_ARG_TYPE/i);
3737
}
3838
});
3939
}

0 commit comments

Comments
 (0)