Skip to content

Commit

Permalink
perf(cli): options for isolated context
Browse files Browse the repository at this point in the history
VM was created for each seprate test run, which caused performance issues. Now it's disabled by default. To get previous behaviour, which is rarely needed, run it with --isolatedContext.
  • Loading branch information
Igmat committed Jun 2, 2018
1 parent a09b925 commit ec05bfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/baset-cli/src/commands/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface ITestArgs extends IGlobalArgs {
bases: string;
specs: string;
reporter: string;
isolateContext: boolean;
}

const testCommand: CommandModule = {
Expand All @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions packages/baset-cli/src/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface ITestGroupPlugins {
readers?: string[] | string;
resolvers?: string[] | string;
imports?: string[] | string;
isolateContext?: boolean;
}

function groupPlugins(plugins: string[]): ITestGroupOptions {
Expand All @@ -31,6 +32,7 @@ function groupPlugins(plugins: string[]): ITestGroupOptions {
readers,
resolvers,
imports,
isolateContext: false,
};
}
function getDefaultPlugins(plugins: ITestGroupPlugins): ITestGroupOptions {
Expand All @@ -52,6 +54,7 @@ function getDefaultPlugins(plugins: ITestGroupPlugins): ITestGroupOptions {
? plugins.imports
: [plugins.imports]
: []).map(resolveModule),
isolateContext: !!plugins.isolateContext,
};
}
function resolveModule<T extends string | undefined>(name: T) {
Expand Down

0 comments on commit ec05bfa

Please sign in to comment.