diff --git a/src/workerRunner.ts b/src/workerRunner.ts index fa98032..4cc5a93 100644 --- a/src/workerRunner.ts +++ b/src/workerRunner.ts @@ -92,12 +92,16 @@ export class WorkerRunner extends EventEmitter { this._loader = new Loader(); this._loader.deserialize(this._params.loader); this._runList = this._loader.runLists()[this._params.runListIndex]; + const tags = this._runList.tags.join('-'); const sameTagsAndTestType = this._loader.runLists().filter(runList => runList.tags.join('-') === tags && runList.testType === this._runList.testType); if (sameTagsAndTestType.length > 1) this._outputPathSegment = tags + (sameTagsAndTestType.indexOf(this._runList) + 1); else this._outputPathSegment = tags; + if (this._outputPathSegment) + this._outputPathSegment = '-' + this._outputPathSegment; + this._config = this._loader.config(this._runList); this._workerInfo = { workerIndex: this._params.workerIndex, @@ -222,10 +226,10 @@ export class WorkerRunner extends EventEmitter { const baseOutputDir = (() => { let suffix = this._outputPathSegment; if (entry.retry) - suffix += (suffix ? '-' : '') + 'retry' + entry.retry; + suffix += '-retry' + entry.retry; if (this._params.repeatEachIndex) - suffix += (suffix ? '-' : '') + 'repeat' + this._params.repeatEachIndex; - return path.join(config.outputDir, relativeTestPath, suffix); + suffix += '-repeat' + this._params.repeatEachIndex; + return path.join(config.outputDir, relativeTestPath + suffix); })(); const testInfo: TestInfo = { ...this._workerInfo, diff --git a/test/test-output-dir.spec.ts b/test/test-output-dir.spec.ts index 266fc52..47d43a6 100644 --- a/test/test-output-dir.spec.ts +++ b/test/test-output-dir.spec.ts @@ -21,8 +21,8 @@ test('should work and remove empty dir', async ({ runInlineTest }) => { 'my-test.spec.js': ` test('test 1', async ({}, testInfo) => { if (testInfo.retry) { - expect(testInfo.outputDir).toContain(require('path').join('my-test', 'test-1', 'retry1')); - expect(testInfo.outputPath('foo', 'bar')).toContain(require('path').join('my-test', 'test-1', 'retry1', 'foo', 'bar')); + expect(testInfo.outputDir).toContain(require('path').join('my-test', 'test-1-retry1')); + expect(testInfo.outputPath('foo', 'bar')).toContain(require('path').join('my-test', 'test-1-retry1', 'foo', 'bar')); } else { expect(testInfo.outputDir).toContain(require('path').join('my-test', 'test-1')); expect(testInfo.outputPath()).toContain(require('path').join('my-test', 'test-1')); @@ -83,22 +83,22 @@ test('should include runWith tag', async ({ runInlineTest }) => { expect(result.results[1].status).toBe('passed'); // test1, run with first env - expect(result.output).toContain('test-results/my-test/test-1/foo1/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-1-foo1/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-1/snapshots1/bar.txt'); - expect(result.output).toContain('test-results/my-test/test-1/foo1-retry1/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-1-foo1-retry1/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-1/snapshots1/bar.txt'); // test1, run with second env - expect(result.output).toContain('test-results/my-test/test-1/foo2/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-1-foo2/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-1/snapshots2/bar.txt'); - expect(result.output).toContain('test-results/my-test/test-1/foo2-retry1/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-1-foo2-retry1/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-1/snapshots2/bar.txt'); // test2, run with env and tag=foo - expect(result.output).toContain('test-results/my-test/test-2/foo/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-2-foo/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-2/snapshots1/bar.txt'); // test2, run with env and tag=a,b - expect(result.output).toContain('test-results/my-test/test-2/a-b/bar.txt'); + expect(result.output).toContain('test-results/my-test/test-2-a-b/bar.txt'); expect(result.output).toContain('__snapshots__/my-test/test-2/snapshots1/bar.txt'); });