Skip to content

Bug: Unknown file extension ".ts" for playwright.config.ts #90

Description

@kmedara

Given

import { defineConfig, devices } from '@playwright/test'
import { defineBddConfig } from 'playwright-bdd'

const testDir = defineBddConfig({
    paths: ['./sample.feature'],
    require:['./steps.ts']
})

export default defineConfig({
  testDir,
//...defaults
})

When

  • i run npx bddgen && playwright test

Then

  • I receive the error
node:internal/modules/esm/get_format:160
  throw new ERR_UNKNOWN_FILE_EXTENSION(ext, filepath);
        ^

TypeError: Unknown file extension ".ts" for K:\source\playwright-bdd-example\playwright.config.ts
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:160:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:203:36)
    at defaultLoad (node:internal/modules/esm/load:143:22)
    at ModuleLoader.load (node:internal/modules/esm/loader:409:7)
    at ModuleLoader.moduleProvider (node:internal/modules/esm/loader:291:45)
    at link (node:internal/modules/esm/module_job:76:21) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

But I expect
Bdd scenarios to be transformed to playwright tests and run

Isolated demo
Reproduced using the example demo and setting type:module

Environment

platform: win32
node: v20.11.0
playwright-bdd: v5.7.1
@playwright/test: v1.40.0
@cucumber/cucumber: v9.2.0
Playwright config file: playwright.config.ts

I've tried a few working arounds listed here but to no avail

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions