Skip to content

Commit

Permalink
Make include optional
Browse files Browse the repository at this point in the history
  • Loading branch information
nayeemrmn committed Sep 21, 2019
1 parent 918fdf9 commit 40bd039
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions testing/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export async function findTestModules(
}

export interface RunTestModulesOptions extends RunTestsOptions {
include?: string[];
exclude?: string[];
allowNone?: boolean;
}
Expand All @@ -128,29 +129,31 @@ export interface RunTestModulesOptions extends RunTestsOptions {
*
* Example:
*
* runTestModules(["**\/*_test.ts", "**\/test.ts"]);
* runTestModules({ include: ["**\/*_test.ts", "**\/test.ts"] });
*
* Any matched directory `<dir>` will expand to:
* <dir>/**\/?(*_)test.{js,ts}
*
* So the above example is captured naturally by:
*
* runTestModules(["."]);
* runTestModules({ include: ["."] });
*
* Which is the default used for:
*
* runTestModules();
*/
// TODO: Change return type to `Promise<void>` once, `runTests` is updated
// to return boolean instead of exiting.
export async function runTestModules(
include: string[],
{
exclude = [],
allowNone = false,
parallel = false,
exitOnFail = false,
only = /[^\s]/,
skip = /^\s*$/,
disableLog = false
}: RunTestModulesOptions = {}
): Promise<void> {
export async function runTestModules({
include = ["."],
exclude = [],
allowNone = false,
parallel = false,
exitOnFail = false,
only = /[^\s]/,
skip = /^\s*$/,
disableLog = false
}: RunTestModulesOptions = {}): Promise<void> {
const testModuleUrls = await findTestModules(include, exclude);

if (testModuleUrls.length == 0) {
Expand Down Expand Up @@ -213,7 +216,8 @@ async function main(): Promise<void> {
const exitOnFail = parsedArgs.failfast;
const disableLog = parsedArgs.quiet;

await runTestModules(include, {
await runTestModules({
include,
exclude,
allowNone,
exitOnFail,
Expand Down

0 comments on commit 40bd039

Please sign in to comment.