question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] svelte + 1.18.0-alpha: SyntaxError: The requested module '@playwright/test' does not provide an export named 'PlaywrightTestConfig'

See original GitHub issue

Context:

  • Playwright Version: @playwright/test@1.18.0-alpha-jan-10-2022
  • Operating System: Linux
  • Node.js version: v16.13.2
  • Browser: <didn’t reach this part>
  • Extra:

System:

  • OS: Linux 5.15 NixOS 22.05 (Quokka) 22.05 (Quokka)
  • Memory: 740.97 MB / 15.51 GB
  • Container: Yes

Binaries:

  • Node: 16.13.2 - /nix/store/1s5l90kdzz5ii4bafi2dnyzv3smziq49-nodejs-16.13.2/bin/node
  • npm: 8.1.2 - /nix/store/1s5l90kdzz5ii4bafi2dnyzv3smziq49-nodejs-16.13.2/bin/npm

Languages:

  • Bash: 5.1.12 - /run/current-system/sw/bin/bash

Code Snippet

# Skeleton project, Typescript, Eslint, Prettier
npm init svelte@next svelte-playwright
cd svelte-playwright
npm install

# Typescript, "tests", true, false
npm init playwright
npx playwright test

I get: Error: playwright.config.ts: Cannot import a typescript file from an esmodule.

try 1.18.0-alpha:

npm i --save-dev @playwright/test@1.18.0-alpha-jan-10-2022
PW_EXPERIMENTAL_TS_ESM=1 npx playwright test

I get:

(node:62468) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Using config at /home/bbigras/dev/svelte-playwright/playwright.config.ts
file:///home/bbigras/dev/svelte-playwright/playwright.config.ts:1
import { PlaywrightTestConfig, devices } from '@playwright/test';
         ^^^^^^^^^^^^^^^^^^^^
SyntaxError: The requested module '@playwright/test' does not provide an export named 'PlaywrightTestConfig'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:181:5)
    at async Promise.all (index 0)
    at ESMLoader.import (node:internal/modules/esm/loader:281:24)
    at importModuleDynamicallyWrapper (node:internal/vm/module:437:15)
    at Loader._requireOrImport (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/loader.js:260:28)
    at Loader.loadConfigFile (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/loader.js:77:18)
    at loadConfig (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/runner.js:91:24)
    at loadConfigFromDirectory (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/runner.js:98:24)
    at Runner.loadConfigFromFile (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/runner.js:107:22)
    at runTests (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/cli.js:148:18)
    at Command.<anonymous> (/home/bbigras/dev/svelte-playwright/node_modules/@playwright/test/lib/cli.js:73:7)

Describe the bug

maybe related to #7121

Same thing with v1.18.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:18 (3 by maintainers)

github_iconTop GitHub Comments

17reactions
pavelfeldmancommented, Feb 1, 2022

Typescript and ESM are not yet best friends, replace first line with:

import type { PlaywrightTestConfig } from '@playwright/test';
import { devices } from '@playwright/test';
3reactions
asdf23commented, Feb 23, 2022

I am now receiving this error after upgrading from 1.17.2 to 1.19.2

If I alter file node_modules/@playwright/test/lib/loader.js

  isModule = false;    // <---  force this to false
  if (isModule) {
    return await esmImport(); 
  }

then it starts working again.

Also using the generated playwright.config.ts file does not resolve this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest, ES6 modules "does not provide export named"
The problem I have is that my app is built with ES6 modules and Jest ES6 modules is experimental and it seems that...
Read more >
dgozman - npm
A customizable test framework to build your own test frameworks. Foundation for the [Playwright test runner](https://github.com/microsoft/playwright-test).
Read more >
Named exports • Svelte Examples
Interactive example Svelte apps.
Read more >
Why Playwright instead of Cypress : r/sveltejs - Reddit
There are several differences between the two, but my guess is because Cypress doesn't support Webkit-based browsers and has an imperative ...
Read more >
JavaScript Daily on Twitter: "Playwright Can Now Test React ...
Playwright Can Now Test React, Vue.js or Svelte Components: github.com. Release v1.22.0 · microsoft/playwright.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found