1.4.3 • Published 5 months ago

@qavajs/playwright-runner-adapter v1.4.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 months ago

npm version

@qavajs/playwright-runner-adapter

Adapter to run cucumber tests via playwright test runner

Installation

npm install @qavajs/playwright-runner-adapter

Basic Configuration

Create cucumber config file

Set paths and require properties

export default {
    paths: ['test/features/*.feature'],
    require: ['test/step_definitions/*.ts']
}

Set testDir

Set testDir to adapter

import { defineCucumber } from '@qavajs/playwright-runner-adapter';

export default defineConfig({
    testDir: defineCucumber({
        config: 'test/cucumber.ts',
        profile: 'default'
    })
});

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 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

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')
})

Limitation

  • ES modules are not supported (at least for node <= 22, where experimental ESM require is introduced)
  • setParallelCanAssign is not supported (use playwright projects and fullyParallel property)
1.2.0

9 months ago

1.1.1

9 months ago

1.1.0

10 months ago

1.0.1

10 months ago

1.0.0

11 months ago

1.4.3

5 months ago

1.4.2

5 months ago

1.4.1

5 months ago

1.4.0

6 months ago

1.3.0

9 months ago

0.7.0

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.3.0

1 year ago

0.4.0

1 year ago

0.2.0

1 year ago

0.1.1

2 years ago

0.1.0

2 years ago