Skip to content

Commit

Permalink
test: set reporter in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vitalets committed Sep 8, 2024
1 parent 9822762 commit 4744444
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 20 deletions.
5 changes: 2 additions & 3 deletions test/bdd-syntax/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

export default defineConfig({
// ignore b/c it contains test.only
testIgnore: 'only-skip-fixme.feature.spec.js',
projects: [
{
name: 'pw-style',
Expand All @@ -22,4 +20,5 @@ export default defineConfig({
}),
},
],
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
3 changes: 2 additions & 1 deletion test/cjs/playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { defineConfig } = require('@playwright/test');
const { defineBddConfig } = require('playwright-bdd');
const { defineBddConfig, cucumberReporter } = require('playwright-bdd');

const testDir = defineBddConfig({
paths: ['*.feature'],
Expand All @@ -8,4 +8,5 @@ const testDir = defineBddConfig({

module.exports = defineConfig({
testDir,
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
3 changes: 2 additions & 1 deletion test/component-tests/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/experimental-ct-react';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

const testDir = defineBddConfig({
paths: ['features'],
Expand All @@ -14,4 +14,5 @@ export default defineConfig({
use: {
screenshot: 'only-on-failure',
},
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
3 changes: 2 additions & 1 deletion test/decorators/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

const testDir = defineBddConfig({
paths: ['features/*.feature'],
Expand All @@ -8,4 +8,5 @@ const testDir = defineBddConfig({

export default defineConfig({
testDir,
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
9 changes: 5 additions & 4 deletions test/esm-ts/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

export default defineConfig({
reporter: [['./reporter.ts']],
// for debug
// reporter: 'html',
reporter: [
['./reporter.ts'],
cucumberReporter('html', { outputFile: 'actual-reports/report.html' }),
],
projects: [
{
name: 'project one',
Expand Down
3 changes: 2 additions & 1 deletion test/esm/playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

export default defineConfig({
projects: [
Expand All @@ -21,4 +21,5 @@ export default defineConfig({
}),
},
],
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
3 changes: 2 additions & 1 deletion test/fixtures/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

export default defineConfig({
workers: 1, // set 1 worker for testing worker scoped fixtures
Expand All @@ -21,4 +21,5 @@ export default defineConfig({
}),
},
],
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
3 changes: 2 additions & 1 deletion test/hooks-fixtures/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

export default defineConfig({
workers: 1,
Expand All @@ -21,4 +21,5 @@ export default defineConfig({
}),
},
],
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
2 changes: 1 addition & 1 deletion test/i18n/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ const testDir = defineBddConfig({

export default defineConfig({
testDir,
reporter: [cucumberReporter('html', { outputFile: 'reports/report.html' })],
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});
2 changes: 1 addition & 1 deletion test/i18n/test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ function checkGeneratedSpecFile() {
}

function checkHtmlReport() {
expect(testDir.getFileContents('reports/report.html')).toContain('Сценарий');
expect(testDir.getFileContents('actual-reports/report.html')).toContain('Сценарий');
}
7 changes: 5 additions & 2 deletions test/projects/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from '@playwright/test';
import { defineBddProject } from 'playwright-bdd';
import { defineBddProject, cucumberReporter } from 'playwright-bdd';

// Exporting const from config and importing in test is shown in Playwright docs.
// This leads to re-evaluation of config in worker and re-call of defineBddConfig().
Expand All @@ -9,7 +9,10 @@ import { defineBddProject } from 'playwright-bdd';
export const FOO = 'foo';

export default defineConfig({
reporter: 'line',
reporter: [
['line'], // prettier-ignore
cucumberReporter('html', { outputFile: 'actual-reports/report.html' }),
],
projects: [
{
...defineBddProject({
Expand Down
7 changes: 4 additions & 3 deletions test/special-tag-only/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { defineConfig } from '@playwright/test';
import { defineBddConfig } from 'playwright-bdd';
import { defineBddConfig, cucumberReporter } from 'playwright-bdd';

const testDir = defineBddConfig({
paths: ['features'],
require: ['steps/*.ts'],
features: 'features',
featuresRoot: 'features',
steps: 'steps/*.ts',
});

export default defineConfig({
testDir,
reporter: [cucumberReporter('html', { outputFile: 'actual-reports/report.html' })],
});

0 comments on commit 4744444

Please sign in to comment.