Skip to content

Commit

Permalink
test: html reporter move specs into features
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Dec 11, 2024
1 parent ac355eb commit 2f9db06
Show file tree
Hide file tree
Showing 23 changed files with 391 additions and 406 deletions.
12 changes: 10 additions & 2 deletions test/reporter-cucumber-html/check-report/fixtures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { test as base } from '@playwright/test';
import { HtmlReport } from './poms/HtmlReport';
import { Feature } from './poms/Feature';
import { Scenario } from './poms/Scenario';
import path from 'node:path';

type Fixtures = {
htmlReport: HtmlReport;
Expand All @@ -18,11 +19,18 @@ export const test = base.extend<Fixtures>({
},
htmlReport: async ({ page }, use) => use(new HtmlReport(page)),
featureUri: ['', { option: true }], // will be overwritten in test files
feature: async ({ htmlReport, featureUri }, use) => {
if (!featureUri) throw new Error('Missing featureUri');
feature: async ({ htmlReport }, use, testInfo) => {
const featureUri = getFeatureUriFromTestFile(testInfo.file);
await use(htmlReport.getFeature(featureUri));
},
scenario: async ({ feature }, use, testInfo) => {
await use(feature.getScenario(testInfo.title));
},
});

function getFeatureUriFromTestFile(file: string) {
const featureFilename = path.basename(file).replace(/\.spec\.ts$/, '');
const featureDir = path.resolve(path.dirname(file), '..');
const featurePath = path.join(featureDir, featureFilename);
return path.relative(process.cwd(), featurePath);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { defineConfig } from '@playwright/test';

export default defineConfig({
testDir: './specs',
testDir: '../features',
outputDir: './test-results',
reporter: 'dot',
use: {
Expand Down
140 changes: 0 additions & 140 deletions test/reporter-cucumber-html/check-report/specs/failing-after.test.ts

This file was deleted.

This file was deleted.

104 changes: 0 additions & 104 deletions test/reporter-cucumber-html/check-report/specs/failing-before.test.ts

This file was deleted.

Loading

0 comments on commit 2f9db06

Please sign in to comment.