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

ERR_REQUIRE_ESM on Windows 10 #11

Open
frederikhors opened this issue Feb 19, 2022 · 0 comments
Open

ERR_REQUIRE_ESM on Windows 10 #11

frederikhors opened this issue Feb 19, 2022 · 0 comments

Comments

@frederikhors
Copy link

I'm on Windows 10 in a new SvelteKit project, "playwright-watch": "1.3.23".

I'm having this error calling it with npx playwright-watch test:

C:\project\node_modules\cosmiconfig\dist\loaders.js:32
    throw error;

Error [ERR_REQUIRE_ESM]: require() of ES Module C:\project\playwright.config.js from C:\project\node_modules\cosmiconfig\dist\loaders.js not supported.
Instead change the require of playwright.config.js in C:\project\node_modules\cosmiconfig\dist\loaders.js to a dynamic import() which is available in all CommonJS modules.
    at module.exports (C:\project\node_modules\import-fresh\index.js:32:59)
    at loadJs (C:\project\node_modules\cosmiconfig\dist\loaders.js:16:18)
    at ExplorerSync.loadFileContentSync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:84:26)
    at ExplorerSync.createCosmiconfigResultSync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:89:30)
    at ExplorerSync.loadSearchPlaceSync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:70:25)
    at ExplorerSync.searchDirectorySync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:55:32)
    at run (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:35:27)
    at cacheWrapperSync (C:\project\node_modules\cosmiconfig\dist\cacheWrapper.js:28:18)
    at ExplorerSync.searchFromDirectorySync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:47:49)
    at ExplorerSync.searchSync (C:\project\node_modules\cosmiconfig\dist\ExplorerSync.js:27:25)
    at getWatchPath (C:\project\node_modules\playwright-watch\dist\lib\getWatchPath.js:7:22)
    at Object.defaultCommand [as handler] (C:\project\node_modules\playwright-watch\dist\commands\defaultCommand.js:9:9)
    at C:\project\node_modules\yargs\build\index.cjs:1:9052
    at j (C:\project\node_modules\yargs\build\index.cjs:1:4931)
    at M.applyMiddlewareAndGetResult (C:\project\node_modules\yargs\build\index.cjs:1:9021)
    at M.runCommand (C:\project\node_modules\yargs\build\index.cjs:1:7206)
    at Jt.[runYargsParserAndExecuteCommands] (C:\project\node_modules\yargs\build\index.cjs:1:56370)
    at Jt.parse (C:\project\node_modules\yargs\build\index.cjs:1:38250)
    at Jt.get [as argv] (C:\project\node_modules\yargs\build\index.cjs:1:59486)
    at Object.<anonymous> (C:\project\node_modules\playwright-watch\dist\bin\playwright-watch.js:45:25) {
  code: 'ERR_REQUIRE_ESM'
}

with this playwright.config.js:

// import type { PlaywrightTestConfig } from "@playwright/test";
// @ts-check
import { devices } from "@playwright/test";

// const config: PlaywrightTestConfig = {
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config = {
	forbidOnly: !!process.env.CI,
	retries: process.env.CI ? 2 : 0,
	testDir: "./tests",
	use: {
		trace: "on-first-retry",
		screenshot: "only-on-failure",
	},
	projects: [
		{
			name: "chromium",
			use: { ...devices["Desktop Chrome"] },
		},
		{
			name: "firefox",
			use: { ...devices["Desktop Firefox"] },
		},
		{
			name: "webkit",
			use: { ...devices["Desktop Safari"] },
		},
	],
};

export default config;

and this example.spec.js:

import { test, expect } from "@playwright/test";

test("basic test", async ({ page }) => {
	await page.goto("http://localhost:3000");
	const title = page.locator("h1");
	await expect(title).toHaveText("h1");
});

Why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant