@qavajs/playwright-runner-adapter
v2.1.0
Published
adapter for playwright test runner
Readme
@qavajs/playwright-runner-adapter
Adapter to run cucumber tests via playwright test runner
Installation
npm install @qavajs/playwright-runner-adapterBasic Configuration
Create cucumber config file
Set paths and require properties
// cucumber.config.ts
import { defineConfig } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
paths: ['test/features/*.feature'],
require: ['test/step_definitions/*.ts']
})Set testMatch property
Set testMatch to adapter
import { defineConfig } from '@playwright/test';
export default defineConfig({
testMatch: 'cucumber.config.ts'
});Advanced Configuration
Customizing test instance
Custom test instance can be passed to world constructor as test property.
And then fixtures can be connected with world instance via init function-property.
import { test as base, expect as baseExpect } from '@playwright/test';
import { SettingsPage } from './settings-page';
import { setWorldConstructor, PlaywrightWorld } from '@qavajs/playwright-runner-adapter';
type MyFixtures = {
settingsPage: SettingsPage;
};
const customTest = base.extend<MyFixtures>({
settingsPage: async ({ page }, use) => {
await use(new SettingsPage(page));
},
});
const customExpect = baseExpect.extend({
async customMatcher() {
// implementation
}
});
class ExtendedPlaywrightWorld extends PlaywrightWorld {
settingsPage: SettingsPage;
constructor(options: any) {
super(options);
}
// set test property with extened one
test = customTest;
expect = customExpect;
// init arrow function connects fixtures with Cucumber world instance
init = ({ settingsPage }) => {
this.settingsPage = settingsPage;
}
}Tag expression and filter
It is possible to use regular tag expressions via tags util function
import { tags } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
grep: tags('@oneTag and @anotherTag')
});or filter tests by predicate
import { filter } from '@qavajs/playwright-runner-adapter';
export default defineConfig({
grep: filter(name => name.includes('login test'))
});Limitation
- ES modules are not supported (at least for node <= 22, where experimental ESM require is introduced)
setParallelCanAssignis not supported (use playwright projects andfullyParallelproperty)CUCUMBER_PARALLEL,CUCUMBER_TOTAL_WORKERSandCUCUMBER_WORKER_IDenv vars are not supported. Use built-ininfo()method of world propertytest
