Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 19 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"url": "https://github.com/qavajs/playwright-runner-adapter/issues"
},
"dependencies": {
"@cucumber/gherkin": "^36.1.0",
"@cucumber/gherkin": "^37.0.0",
"@cucumber/tag-expressions": "^8.0.0",
"glob": "^12.0.0",
"glob": "^13.0.0",
"@cucumber/cucumber": "^12.2.0"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions src/cucumber.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ for (const feature of features) {
.annotations
.find((annotation: { type: string }) => annotation.type === 'testId')
.description;
const testCase = tests.find(test => test.id === testId);
const testCase = tests.find(test => test.id === testId)!;
for (const beforeHook of supportCodeLibrary.beforeTestCaseHookDefinitions) {
if (beforeHook.appliesToTestCase(testCase)) {
const hookName = beforeHook.name ?? 'Before';
Expand Down Expand Up @@ -161,7 +161,7 @@ for (const feature of features) {
.annotations
.find((annotation: { type: string }) => annotation.type === 'testId')
.description;
const testCase = tests.find(test => test.id === testId);
const testCase = tests.find(test => test.id === testId)!;
for (const afterHook of supportCodeLibrary.afterTestCaseHookDefinitions) {
if (afterHook.appliesToTestCase(testCase)) {
const hookName = afterHook.name ?? 'After';
Expand Down
13 changes: 10 additions & 3 deletions src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { join, resolve } from 'node:path';
import { randomUUID } from 'node:crypto';
import { AstBuilder, compile, GherkinClassicTokenMatcher, Parser } from '@cucumber/gherkin';
import { supportCodeLibraryBuilder } from '@cucumber/cucumber';
import type { Pickle, GherkinDocument } from '@cucumber/messages';
import { globSync } from 'glob';
import { PlaywrightWorld } from './PlaywrightWorld';

Expand All @@ -11,7 +12,7 @@ const builder = new AstBuilder(uuidFn);
const matcher = new GherkinClassicTokenMatcher();
const parser = new Parser(builder, matcher)

function duplicates(tests: any[]) {
function duplicates(tests: readonly Pickle[]) {
const counts: Record<string, number> = {};
return tests.map(item => {
const name = item.name;
Expand All @@ -26,15 +27,21 @@ function duplicates(tests: any[]) {
});
}

export function loadFeatures(globPattern: string[]) {
type Feature = {
feature?: string;
gherkinDocument: GherkinDocument;
tests: readonly Pickle[];
}

export function loadFeatures(globPattern: string[]): Feature[] {
const files = globSync(globPattern);
return files.map(file => {
const filePath = resolve(file);
const gherkinDocument = parser.parse(readFileSync(filePath, 'utf-8'));
return {
feature: gherkinDocument.feature?.name,
gherkinDocument,
tests: duplicates(compile(gherkinDocument, file, uuidFn) as any)
tests: duplicates(compile(gherkinDocument, file, uuidFn))
}
});
}
Expand Down
Loading