diff --git a/index.ts b/index.ts
index 8762ab3..6a9519c 100644
--- a/index.ts
+++ b/index.ts
@@ -179,19 +179,28 @@ export class Scenarios {
* with name name of the base scenario: -.
* @returns a new `Scenarios` instance with the given scenario removed.
*/
- skip(variantName: string): Scenarios {
+ skip(): Scenarios;
+ skip(variantName: string): Scenarios;
+ skip(variantName?: string): Scenarios {
if (this.state.type === 'root') {
- throw new Error(`no variant named ${variantName} available to skip on root scenario`);
- }
- if (!this.state.variants[variantName]) {
- throw new Error(
- `no variant named ${variantName} available to skip. Found variants: ${Object.keys(
- this.state.variants
- ).join(', ')}`
- );
+ throw new Error('cannot call skip() on root scenarios');
}
+
let variants = Object.assign({}, this.state.variants);
- variants[variantName].status = 'skipped';
+ if (variantName) {
+ if (!this.state.variants[variantName]) {
+ throw new Error(
+ `no variant named ${variantName} available to skip. Found variants: ${Object.keys(
+ this.state.variants
+ ).join(', ')}`
+ );
+ }
+ variants[variantName].status = 'skipped';
+ } else {
+ for (let variant of Object.values(variants)) {
+ variant.status = 'skipped';
+ }
+ }
return new Scenarios({
type: 'derived',
parent: this.state.parent,
@@ -199,7 +208,6 @@ export class Scenarios {
});
}
-
/**
* @param variantName - name of scenario to keep. Note: names of derived scenarios are prepended
* with name name of the base scenario: -.
diff --git a/tests/test.ts b/tests/test.ts
index ec29a9e..e95fbcd 100644
--- a/tests/test.ts
+++ b/tests/test.ts
@@ -72,6 +72,15 @@ ok 1 project > createHello
});
});
+const skipExpandedExample = Scenarios.fromProject(() => new Project());
+skipExpandedExample
+ .expand({
+ 'child-one-of-other-root': () => {},
+ 'child-two-of-other-root': () => {},
+ }).skip().map('inner', () => {}) // skip with no arguments skips all variants
+ .forEachScenario(() => {});
+
+
Qunit.module('cli', () => {
Qunit.test('list', async (assert) => {
const result = await execa('node', ['./dist/cli.js', 'list', '--require', 'ts-node/register', '--files', './tests/test.ts', '--matrix'])