node/lib/internal/test_runner/utils.js
Colin Ihrig adaf602405
test_runner: add initial CLI runner
This commit introduces an initial version of a CLI-based
test runner.

PR-URL: https://github.com/nodejs/node/pull/42658
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-04-15 18:37:28 +01:00

16 lines
489 B
JavaScript

'use strict';
const { RegExpPrototypeExec } = primordials;
const { basename } = require('path');
const kSupportedFileExtensions = /\.[cm]?js$/;
const kTestFilePattern = /((^test(-.+)?)|(.+[.\-_]test))\.[cm]?js$/;
function doesPathMatchFilter(p) {
return RegExpPrototypeExec(kTestFilePattern, basename(p)) !== null;
}
function isSupportedFileType(p) {
return RegExpPrototypeExec(kSupportedFileExtensions, p) !== null;
}
module.exports = { isSupportedFileType, doesPathMatchFilter };