Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kmedara opened this issue Feb 10, 2024 · 2 comments
Closed

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

kmedara opened this issue Feb 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@kmedara
Copy link

kmedara commented Feb 10, 2024

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

@kmedara kmedara added the bug Something isn't working label Feb 10, 2024
@vitalets
Copy link
Owner

Hi @kmedara ! Thanks for highlighting that.
I've created a working example in ESM. Could you check the diff and let me know does it work in your vite + vue3 setup.

I will update getting starting section in docs for ESM.

@vitalets
Copy link
Owner

Improved ESM docs and added fully working ESM example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants