diff --git a/index.ts b/index.ts index 6a9519c..4e7b208 100644 --- a/index.ts +++ b/index.ts @@ -186,12 +186,18 @@ export class Scenarios { throw new Error('cannot call skip() on root scenarios'); } - let variants = Object.assign({}, this.state.variants); + let variants = Object.fromEntries( + Object.entries(this.state.variants).map(([variantName, entry]) => [ + variantName, + Object.assign({}, entry), + ]) + ); + if (variantName) { - if (!this.state.variants[variantName]) { + if (!variants[variantName]) { throw new Error( `no variant named ${variantName} available to skip. Found variants: ${Object.keys( - this.state.variants + variants ).join(', ')}` ); } diff --git a/tests/test.ts b/tests/test.ts index e95fbcd..dc0761a 100644 --- a/tests/test.ts +++ b/tests/test.ts @@ -72,14 +72,17 @@ 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 +const skipTester = Scenarios.fromProject(() => new Project()).expand({ + 'variant-one': () => {}, + 'variant-two': () => {}, +}) + + +skipTester.skip().map('skipped', () => {}) // skip with no arguments skips all variants .forEachScenario(() => {}); +skipTester.map('not-skipped', () => {} ).forEachScenario(() => {}); + Qunit.module('cli', () => { Qunit.test('list', async (assert) => { @@ -88,7 +91,7 @@ Qunit.module('cli', () => { const { stdout } = result; assert.deepEqual( stdout.split('\n'), - ['hello1', 'hello2'] + ['hello1', 'hello2', 'variant-one-not-skipped', 'variant-two-not-skipped'] ); }); });