Rayrun
← Back to Discord Forum

I cannot run electron app

javierguzmandevposted in #help-playwright
Open in Discord
javierguzmandev
javierguzmandev

Hello all,

I am trying to use Playwright to test an Electron app. Here is my test:

import { _electron as electron, ElectronApplication, test, Page } from "@playwright/test";

let electronApp: ElectronApplication;
let page: Page;

test.beforeAll(async () => {
  electronApp = await electron.launch({
    cwd: ".",
    args: ["./.webpack/main/index.js"],
  });
  electronApp.on("window", async initialPage => {
    const filename = initialPage.url()?.split("/").pop();
    console.log(`Window opened: ${filename}`);

    initialPage.on("pageerror", error => {
      console.error(error);
    });

    initialPage.on("console", msg => {
      console.log(msg.text());
    });
  });
});

test("renders landing page", async () => {
  page = await electronApp.firstWindow();
  await page.screenshot({ path: "landing.png" });
});

test.afterAll(async () => {
  await electronApp.close();
});

However, when I run playwright I get the error:

Error: ENOENT: no such file or directory, open 'blabla/projectfolder/.webpack/main/package.json'

I do not understand why it needs the package.json to run. I mean, I use Typescript and Electron Forge, so if I make a build I have an out folder where the bundle is. If I am in development mode, then the .webpack folder is the bundle.

So I really do not understand why it is looking for a package.json. What am I missing here?

I would really appreciate any hint.

Thank you in advance and regards

This thread is trying to answer question "Why is the test looking for a package.json file and how can this error be resolved?"

0 replies
TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].