-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Fails to run Playwright browser automtation library #2492
Comments
Was hopeful Bun 0.7 would run my Playwright compatibility tests, but while the process and TLS related-errors (and my workarounds) have gone away, there is some snag seemingly with the import/transpile/node-compat dance taking place... Given the most basic boilerplate code and trying to init a browser, the imports are
Seems to come from fact that playwright-core is using both index.js and index.mjs together? exports field looks like: https://github.com/microsoft/playwright/blob/main/packages/playwright-core/package.json#L14 I've tried rearranging the Playwright source code to hack around this but maybe I don't understand what is happening under the hood |
Same error in 0.7.3. Would be great to have this for 1.0 🙏🏽 |
Same error with 0.8.1 and Playwright 1.37.1 |
Unfortunately, still an issue with v1.0.0 🥲 |
To be clear, there are two separate issues that remain here:
|
same for me(( |
bun 1.0 and playwright package "@playwright/test": "~1.32" works with running "bun run test" (which runs |
@hexagon6 I'd be curious what the contents of testfile.js are? |
@hexagon6 If I'm not mistaken, you actually need to use In this case, adding Even when |
Ah yes, I wondered about that. I don't believe you need |
The testfile (actually called routes.test.js): import { expect, test } from '@playwright/test'
test('about page has expected h1', async ({ page }) => {
await page.goto('/public/about')
expect(await page.textContent('h1')).toBe('About this Web App')
}) And I run it like that: $ bun run test
$ playwright test tests/routes.test.js |
So running with
Full error (which is probably not relevant to this exact issue, but for context):
|
Actually deno has this problem too, but |
This comment was marked as duplicate.
This comment was marked as duplicate.
@Electroid Just curious. What does |
@ngocphamm I assume that Access to Work |
I've learned that Deno also fails to run playwright, and maybe provides some further insight into this problem. Specifically denoland/deno#16899 (comment) So the child_process shim (which Bun is also abstracting over Bun.spawn) needs to support open fds for |
FWIW, not sure entirely similar but - having a similar issue with $ bun --bun run test
$ jest
Test Suites: 0 of 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.085 s
Ran all test suites.
TypeError: undefined is not an object (evaluating 'Module._extensions[".js"]')
at addHook (/builds/mvp/one/web/node_modules/pirates/lib/index.js:90:41)
at <anonymous> (/builds/mvp/one/web/node_modules/@jest/transform/build/ScriptTransformer.js:772:12)
at requireAndTranspileModule (/builds/mvp/one/web/node_modules/@jest/transform/build/ScriptTransformer.js:760:34)
at <anonymous> (/builds/mvp/one/web/node_modules/@jest/core/build/TestScheduler.js:227:42)
at processTicksAndRejections (:55:39)
error: script "test" exited with code 1 (SIGHUP) I switched to ● Test suite failed to run
TypeError: Attempted to assign to readonly property.
at node_modules/jest-runtime/build/index.js:1638:5
at forEach (:1:21)
at Object.<anonymous> (node_modules/stack-utils/index.js:35:4)
at Object.<anonymous> (node_modules/expect/build/toThrowMatchers.js:9:24)
at Object.<anonymous> (node_modules/expect/build/index.js:23:48)
at _expect (node_modules/@jest/expect/build/index.js:8:16)
at createJestExpect (node_modules/@jest/expect/build/index.js:29:3)
at Object.<anonymous> (node_modules/@jest/expect/build/index.js:39:20)
at processTicksAndRejections (:55:77)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.277 s
Ran all test suites. Just putting this here as I feel there might be some overlap. Solution for now is just to use the native bun test runner which works fine. |
Bun 1.0.4 Here got another error :
|
Same for bun 1.0.6 |
command code: const browser = await firefox.launch();
const context = await browser.newContext();
const page = await context.newPage(); Error:
same for bun 1.0.9 |
connecting to an existing browser does not work too. |
Has anyone tried including the |
checked with 1.0.18, still does not work :( |
1.0.20 also does not work. TypeError: undefined is not an object (evaluating 'pipeRead.on') |
With a minimal reproduction I also get an undefined error with bun Minimal reproduction
bunx playwright install
bunx playwright install-deps
mkdir running-playwright-via-bun
bun init playwright@latest
// File name: example.spec.ts
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});
bunx playwright test
# or
bunx playwright test example.spec.ts
|
In the next version of Bun, Playwright seems to work, thanks to @nektro in #7958. Related PR: microsoft/playwright#28875 |
same problem. bun 1.0.21 code:
input: bun index.ts output:
|
PR isn't yet merged so I don't think you'll be able to test it yet |
it work!!
index.ts: import { chromium } from 'playwright';
(async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto('https://bun.sh/');
await page.screenshot({ path: 'screen.png' });
await browser.close();
})(); |
Addresses a significant part of #294, thanks to oven-sh/bun#2492 .
@zoyspace awesome!! Confirmed that running Playwright itself works with Bun runtime! Tests ( Modifying your snippet slightly: import { chromium } from "playwright";
import { test } from "@playwright/test";
test("Bun website", async () => {
const browser = await chromium.launch({ headless: false });
const page = await browser.newPage();
await page.goto("https://bun.sh/");
await page.screenshot({ path: "screen.png" });
}); Result:
|
that's dependent on microsoft/playwright#28935 (which is merged 😃) making it into the next playwright release |
Playwright v1.41.0 which includes the above change has now been tagged and works together with Bun v1.0.22+.
|
yes can confirm that launching a browser now works in bun but the original problem mentioned here hasn't been solved. |
Still not working on my side:
Everything exported
Edit: Test from Bun 1.0.22 to 1.0.26 & with latest 1.41.0/1.41.2 version of playwright |
It's so weird, using |
What version of Bun is running?
0.5.8
What platform is your computer?
Linux 5.4.0-132-generic x86_64 x86_64 (Ubuntu 20.04.5 LTS)
What steps can reproduce the bug?
I put the classic
Playwright
example intestPlaywright.ts
:I get the same error if I rename it to a
.js
fileWhat is the expected behavior?
Playwright should run properly.
What do you see instead?
No response
Additional information
Puppeteer has had issues with Bun: #2316
Also puppeteer and playwright depend on the Node TLS API implementation #781 (comment)_
The text was updated successfully, but these errors were encountered: