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

Theoretically possible to test without packaging? #14

Open
Nantris opened this issue Jan 3, 2023 · 8 comments
Open

Theoretically possible to test without packaging? #14

Nantris opened this issue Jan 3, 2023 · 8 comments

Comments

@Nantris
Copy link

Nantris commented Jan 3, 2023

Thanks for sharing your hard work! Is there any chance in the future that tests will be able to be run without first packaging the application?

@achtan
Copy link

achtan commented Jan 24, 2023

I'm looking for this as well

@Nantris
Copy link
Author

Nantris commented Jan 24, 2023

@achtan theoretically yes, but if you need transpilation then no: microsoft/playwright#19854 (comment)

@jjeff
Copy link
Contributor

jjeff commented Jan 24, 2023

It should be possible now to do Playwright testing without packaging the Electron application. This repository is just an example… and to be honest, most of the work has moved to the electron-playwright-helpers repository. But you would just launch the Electron app by following the normal Playwright Electron instructions. Then you could use the electron-playwright-helpers functions for IPC, menu interactions, and (new feature!) Dialog stubbing.

@achtan
Copy link

achtan commented Jan 25, 2023

@jjeff thanks for the great work. Can you please elaborate more on this? I'm not really familiar with electron nor playwright. Thanks

@jjeff
Copy link
Contributor

jjeff commented Jan 25, 2023

In Electron, you can run your application with a script (usually npm start) that will run the original source without packaging it into an application of its own. It runs using the Electron executable which lives in your node_modules folder. However, if you are using electron-forge or electron-builder, you can build (aka "package") a freestanding application (and installers, .zip, .dmg, .etc).

Playwright's Electron functionality defaults to testing the unpackaged application. This repository and the electron-playwright-helpers library have functionality to help you to test a packaged, free-standing Electron application, more closely resembling the version that you will distribute to your end-users. The challenge of testing a packaged Electron app is discerning its component parts (executable, main javascript file, package.json, etc) in order to tell Playwright how to launch your app.

But if you're testing your unpackaged application, you can simply follow Playwright's example in their documentation. That's a good way to start.

@SabFloki
Copy link

Hi @jjeff - I have similar requirement with Playwright, where need to launch .exe file on windows machine running on OpenFin server and need to access menus which will take to chrome ( chromium shell ).

Will the implementation be similar as above ?

Kindly suggest.

@jjeff
Copy link
Contributor

jjeff commented Feb 12, 2023

The helper functions in the electron-playwright-helpers package should work the same in either a packaged app or an unpackaged one. So you should be able to test menus, ipc functionality, etc, using these functions.

I don't know much about OpenFin and the configuration of Chromium that you're talking about. But if you're not loading Electron, you won't be able to test Electron's menus. Playwright should handle loading/running Electron though -- all of that is outside of the scope of this repository though.

If you haven't already looked at the electron-playwright-helpers repository, please do. Most of the work that started here has moved to there.

@SabFloki
Copy link

Thanks @jjeff . I haven't received the Openfin config yet. I will test it out with electron-playwright-helpers and reach out for help.

This repo has given me idea on how the approach could be taken ahead. Thanks much for this contribution.

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