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] Unable to import module in test [ERR_REQUIRE_ESM] #13065
Comments
I think this is the same I was talking here: #12836 (comment). Can you try with 1.20.0? It works for me. |
@grybykm I cannot repro this on macOS, node v16.14.0. Would you be able to share a full repro? Here is what I tried: // package.json
{
"name": "sample",
"version": "1.0.0",
"type": "module",
"dependencies": {
"get-port": "^6.1.2",
"@playwright/test": "^1.20.1"
},
}
// playwright.config.ts
import { type PlaywrightTestConfig} from '@playwright/test';
const config: PlaywrightTestConfig = {
};
export default config;
// example.spec.ts
import { test } from '@playwright/test'
import getport from 'get-port'
test.describe('suite', () => {
test('test', async ({ page }) => {
console.log(await getport())
await page.goto('https://playwright.dev')
})
})
// command-line
PW_EXPERIMENTAL_TS_ESM=1 npx playwright test example.spec |
@dgozman i have this on windows 10. |
@dgozman your example indeed works for me! ex: the file
another drawback of this approach is that I can't use
|
Makes sense, folding it into #13078 |
@pavelfeldman @dgozman are there any updates on this? A very basic and simple example. A test with some imports and global setup. The doc won't help because it uses global setup, imports doesn't work due to the error
test example
playwright config example
|
@grybykm You should either |
Context:
Code Snippet
Describe the bug
Playwright fails with
no test found
error due to importimport getport from 'get-port'
of a module.PW_EXPERIMENTAL_TS_ESM=1
doesn't help anyhow in any combination with or without"type": "module"
in the package.jsonThe text was updated successfully, but these errors were encountered: