playwright
playwright copied to clipboard
[Bug]: Rollup failed to resolve import "/playwright/index.ts" from "/myrepo/playwright/index.html"
Version
1.43.1
Steps to reproduce
I'm currently upgrading my repository to use "@playwright/experimental-ct-react": "1.43.1" from 1.40.1
When I try to run the playwright tests I now get the following error:
Rollup failed to resolve import "/playwright/index.ts" from "/myrepo/playwright/index.html"
playwright/index.html
contents:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="environment" content="test">
<title>Testing Page</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/playwright/index.ts"></script>
</body>
</html>
playwright/index.ts
contents:
import { beforeMount } from "@playwright/experimental-ct-react/hooks"
beforeMount(async ({ hooksConfig }) => {
if (hooksConfig && hooksConfig.mockDateNow) {
Date.now = () => hooksConfig.mockDateNow as number
}
})
Expected behavior
I expect that it doesn't error out.
Actual behavior
It errors out with the bug mentioned above.
Additional context
No response
Environment
System:
OS: macOS 14.4.1
CPU: (10) arm64 Apple M1 Pro
Memory: 50.33 MB / 16.00 GB
Binaries:
Node: 19.7.0 - ~/.nvm/versions/node/v19.7.0/bin/node
Yarn: 4.1.1 - ~/.nvm/versions/node/v19.7.0/bin/yarn
npm: 9.5.0 - ~/.nvm/versions/node/v19.7.0/bin/npm
IDEs:
VSCode: 1.88.0 - /usr/local/bin/code
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/experimental-ct-react: 1.43.1 => 1.43.1
playwright-core: 1.43.1 => 1.43.1
playwright-testing-library: 4.5.0 => 4.5.0
Try replacing
src="/playwright/index.ts"
with src="./index.ts"
to resolve index.ts properly.
Try replacing
src="/playwright/index.ts"
withsrc="./index.ts"
to resolve index.ts properly.
@pavelfeldman Error is still largely the same: Rollup failed to resolve import "undefined" from "/myrepo/playwright/index.ts"
That's unfortunate. In this case we need a reduced repro in a form of an archive or a repo that we can clone.
Rollup failed to resolve import "undefined" from "/myrepo/playwright/index.ts"
I am getting the same error after upgrading.
@hklsiteimprove @ritz078 I have not been able to reproduce this issue after changing src="/playwright/index.ts"
to src="./index.ts"
.
However, I noticed that your error message contains "/myrepo/playwright/index.html"
. Perhaps you want to set ctTemplateDir: './myrepo/playwright'
in your playwright config next to ctPort
, so that it points to the playwright
directory that contains both index.html
and index.ts
? By default, Playwright looks into ./playwright
directory next to your config.
In any case, if you could share a repro, that would be great. Otherwise, we'll have to close this issue since we cannot reproduce it.
We have to reproduce this issue locally to be able to debug it. If you can provide a full repro, please file a new issue by filling the "Bug Report" template, and link to this one.
@dgozman @pavelfeldman I've added a new issue report on this issue, with repo steps. https://github.com/microsoft/playwright/issues/30689