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]: Rollup failed to resolve import "/playwright/index.ts" from "/myrepo/playwright/index.html" #30565

Closed
hklsiteimprove opened this issue Apr 26, 2024 · 7 comments

Comments

@hklsiteimprove
Copy link

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
@pavelfeldman
Copy link
Member

Try replacing

src="/playwright/index.ts" with src="./index.ts" to resolve index.ts properly.

@hklsiteimprove
Copy link
Author

hklsiteimprove commented Apr 29, 2024

Try replacing

src="/playwright/index.ts" with src="./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"

@pavelfeldman
Copy link
Member

That's unfortunate. In this case we need a reduced repro in a form of an archive or a repo that we can clone.

@ritz078
Copy link

ritz078 commented Apr 30, 2024

Rollup failed to resolve import "undefined" from "/myrepo/playwright/index.ts"

I am getting the same error after upgrading.

@dgozman
Copy link
Contributor

dgozman commented May 2, 2024

@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.

@dgozman
Copy link
Contributor

dgozman commented May 6, 2024

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.

@hklsiteimprove
Copy link
Author

@dgozman @pavelfeldman I've added a new issue report on this issue, with repo steps.
#30689

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

4 participants