Cucumber/Gherkin adapter for @qavajs/tx. Lets you write BDD tests in .feature files and run them through the tx test runner.
npm install @qavajs/tx-runner-adapter// tx.config.ts
import { defineConfig } from '@qavajs/tx';
import { createPreprocessor } from '@qavajs/tx-runner-adapter';
export default defineConfig({
testFiles: ['features/**/*.feature'],
preprocessor: createPreprocessor({
stepDefinitions: ['step-definitions/**/*.ts'],
tags: process.env.TAGS,
}),
});// step-definitions/steps.ts
import { Given, When, Then } from '@qavajs/tx-runner-adapter';
Given('I open {string}', async function (url: string) {
await this.page.goto(url);
});
When('I click {string}', async function (selector: string) {
await this.page.locator(selector).click();
});
Then('I see {string}', async function (text: string) {
await this.expect(this.page.locator('body')).toContainText(text);
});| Option | Type | Description |
|---|---|---|
stepDefinitions |
string | string[] |
Glob pattern(s) for step definition files |
support |
string | string[] |
Glob pattern(s) for support files loaded before step definitions |
tags |
string |
Cucumber tag expression to filter scenarios, e.g. @smoke and not @wip |
The World object (this inside steps) exposes the tx fixtures:
| Property | Type |
|---|---|
page |
Playwright Page |
browser |
Playwright Browser |
expect |
Playwright expect |
request |
Playwright APIRequestContext |
You can extend World by calling setWorldConstructor with a class that extends the built-in World.
import { Before, After, BeforeAll, AfterAll, BeforeStep, AfterStep } from '@qavajs/tx-runner-adapter';
Before(async function () { /* runs before each scenario */ });
After(async function () { /* runs after each scenario */ });
BeforeAll(async function () { /* runs once before all scenarios */ });
AfterAll(async function () { /* runs once after all scenarios */ });
BeforeStep(async function () { /* runs before each step */ });
AfterStep(async function () { /* runs after each step */ });MIT