-
-
Notifications
You must be signed in to change notification settings - Fork 33.5k
Description
What is the problem this feature will solve?
It's quite difficult to run test files matching a "file name pattern" when using run()
function.
It's easy when using CLI, for example:
node --test src/**/*.test.js
It's difficult because it only allows to pass file paths in files option which means I need to use e.g. glob package to find files when I want to replicate the same behaviour when using CLI.
I see it's possible to still provide test file name pattern as command option when when using run()
node runTests.mjs src/**/*.test.js
but I would like to define file name patterns in runTests.mjs
file, based on different conditions.
My use case is to differentiate between unit and integration tests in runTests.mjs
What is the feature you are proposing to solve the problem?
Add new option to run()
function
filePathPatterns
or filePatterns
or testFilePathPatterns
- to specify which files test runner should run by glob pattern, like in CLI
- type:
Array<string>
- example
filePathPatterns: ['src/**/*.integration.test.js']
Additional option to ignore
It would be great to be able to also ignore some tests by file path pattern
so another option like filePathIgnorePatterns
- to specify which files should be ignored by test runner to allow running only selected set of tests (e.g. only integration tests)
I see that internal Glob
implementation has an exclude option so that's what I am talking about
What alternatives have you considered?
Using only CLI for running tests, avoid using run()