From 8476ffb85a31f7dd03e4b08e984cb732802f908c Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Fri, 22 Apr 2022 00:20:44 +0200 Subject: [PATCH] test: use `assert.match()` instead of `assert(regex.test())` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/42803 Reviewed-By: Tobias Nießen Reviewed-By: Luigi Pinca Reviewed-By: James M Snell Reviewed-By: Colin Ihrig Reviewed-By: Mohammed Keyvanzadeh --- test/parallel/test-runner-cli.js | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/parallel/test-runner-cli.js b/test/parallel/test-runner-cli.js index 8d16205cdaf1bc..7bd95372a2d68b 100644 --- a/test/parallel/test-runner-cli.js +++ b/test/parallel/test-runner-cli.js @@ -14,7 +14,7 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.status, 1); assert.strictEqual(child.signal, null); assert.strictEqual(child.stdout.toString(), ''); - assert(/^Could not find/.test(child.stderr.toString())); + assert.match(child.stderr.toString(), /^Could not find/); } { @@ -27,11 +27,11 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert(/ok 1 - .+index\.test\.js/.test(stdout)); - assert(/not ok 2 - .+random\.test\.mjs/.test(stdout)); - assert(/not ok 1 - this should fail/.test(stdout)); - assert(/ok 3 - .+subdir.+subdir_test\.js/.test(stdout)); - assert(/ok 4 - .+random\.cjs/.test(stdout)); + assert.match(stdout, /ok 1 - .+index\.test\.js/); + assert.match(stdout, /not ok 2 - .+random\.test\.mjs/); + assert.match(stdout, /not ok 1 - this should fail/); + assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/); + assert.match(stdout, /ok 4 - .+random\.cjs/); } { @@ -43,11 +43,11 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert(/not ok 1 - .+index\.js/.test(stdout)); - assert(/ok 2 - .+index\.test\.js/.test(stdout)); - assert(/not ok 3 - .+random\.test\.mjs/.test(stdout)); - assert(/not ok 1 - this should fail/.test(stdout)); - assert(/ok 4 - .+subdir.+subdir_test\.js/.test(stdout)); + assert.match(stdout, /not ok 1 - .+index\.js/); + assert.match(stdout, /ok 2 - .+index\.test\.js/); + assert.match(stdout, /not ok 3 - .+random\.test\.mjs/); + assert.match(stdout, /not ok 1 - this should fail/); + assert.match(stdout, /ok 4 - .+subdir.+subdir_test\.js/); } { @@ -59,7 +59,7 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert(/not ok 1 - .+test-nm\.js/.test(stdout)); + assert.match(stdout, /not ok 1 - .+test-nm\.js/); } { @@ -72,11 +72,11 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.signal, null); assert.strictEqual(child.stderr.toString(), ''); const stdout = child.stdout.toString(); - assert(/ok 1 - .+index\.test\.js/.test(stdout)); - assert(/not ok 2 - .+random\.test\.mjs/.test(stdout)); - assert(/not ok 1 - this should fail/.test(stdout)); - assert(/ok 3 - .+subdir.+subdir_test\.js/.test(stdout)); - assert(/ok 4 - .+random\.cjs/.test(stdout)); + assert.match(stdout, /ok 1 - .+index\.test\.js/); + assert.match(stdout, /not ok 2 - .+random\.test\.mjs/); + assert.match(stdout, /not ok 1 - this should fail/); + assert.match(stdout, /ok 3 - .+subdir.+subdir_test\.js/); + assert.match(stdout, /ok 4 - .+random\.cjs/); } { @@ -102,6 +102,6 @@ const testFixtures = fixtures.path('test-runner'); assert.strictEqual(child.signal, null); assert.strictEqual(child.stdout.toString(), ''); const stderr = child.stderr.toString(); - assert(/--test/.test(stderr)); + assert.match(stderr, /--test/); }); }