playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[Bug]: Rollup failed to resolve import "/playwright/index.ts" from "/myrepo/playwright/index.html"

Open hklsiteimprove opened this issue 9 months ago • 5 comments

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

hklsiteimprove avatar Apr 26 '24 12:04 hklsiteimprove

Try replacing

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

pavelfeldman avatar Apr 26 '24 21:04 pavelfeldman

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"

hklsiteimprove avatar Apr 29 '24 07:04 hklsiteimprove

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

pavelfeldman avatar Apr 29 '24 15:04 pavelfeldman

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

I am getting the same error after upgrading.

ritz078 avatar Apr 30 '24 16:04 ritz078

@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 avatar May 02 '24 19:05 dgozman

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 avatar May 06 '24 13:05 dgozman

@dgozman @pavelfeldman I've added a new issue report on this issue, with repo steps. https://github.com/microsoft/playwright/issues/30689

hklsiteimprove avatar May 07 '24 11:05 hklsiteimprove