vitalets/playwright-bdd

Feature: Is there a way to integrate with @chromatic-com/playwright

fschwalm opened this issue · 2 comments

The problem

I am trying to use @chromatic-com/playwright, but I can't pass a test from @chromatic-com/playwright to the createBdd function.
Is there a way to achieve this?

A solution

import { test as chromaticTest } from '@chromatic-com/playwright'
import { test as base, createBdd } from 'playwright-bdd'
const FIXTURES = {
  explorepage: 'http://localhost:3000/explore',
} as const

export const test = base.extend<typeof FIXTURES>(FIXTURES)

export const { Given, When, Then } = createBdd(chromaticTest)

Thank you!!

Could you try mergeTests to get composed test instance:

import { mergeTests } from '@playwright/test';
// ...

export const test = mergeTests(chromaticTest, base).extend<typeof FIXTURES>(FIXTURES)

It worked like a charm.

Thank you so much!!!