diff --git a/packages/baset-cli/src/commands/test.ts b/packages/baset-cli/src/commands/test.ts index 3b908a05..6279f96f 100644 --- a/packages/baset-cli/src/commands/test.ts +++ b/packages/baset-cli/src/commands/test.ts @@ -12,6 +12,7 @@ interface ITestArgs extends IGlobalArgs { bases: string; specs: string; reporter: string; + isolateContext: boolean; } const testCommand: CommandModule = { @@ -37,11 +38,16 @@ const testCommand: CommandModule = { describe: 'TAP reporter to use, `false` for plain output', default: 'tap-diff', }, + isolateContext: { + type: 'boolean', + describe: 'Run each test in isolated context. ATTENTION: this will slow down your tests', + default: false, + }, }, handler: async (argv: ITestArgs) => { let isSucceeded = true; const [allSpecs, allBaselines] = await Promise.all([glob(argv.specs), glob(argv.bases)]); - const tester = new Tester(argv.plugins, argv.options); + const tester = new Tester(argv.plugins, argv.options, argv.isolateContext); const specs = allSpecs.filter(filterNodeModules); const baselines = allBaselines.filter(filterNodeModules); let reporterIsSkipped: boolean; diff --git a/packages/baset-cli/src/options/index.ts b/packages/baset-cli/src/options/index.ts index afac2c42..29efb40d 100644 --- a/packages/baset-cli/src/options/index.ts +++ b/packages/baset-cli/src/options/index.ts @@ -12,6 +12,7 @@ export interface ITestGroupPlugins { readers?: string[] | string; resolvers?: string[] | string; imports?: string[] | string; + isolateContext?: boolean; } function groupPlugins(plugins: string[]): ITestGroupOptions { @@ -31,6 +32,7 @@ function groupPlugins(plugins: string[]): ITestGroupOptions { readers, resolvers, imports, + isolateContext: false, }; } function getDefaultPlugins(plugins: ITestGroupPlugins): ITestGroupOptions { @@ -52,6 +54,7 @@ function getDefaultPlugins(plugins: ITestGroupPlugins): ITestGroupOptions { ? plugins.imports : [plugins.imports] : []).map(resolveModule), + isolateContext: !!plugins.isolateContext, }; } function resolveModule(name: T) {