spectron icon indicating copy to clipboard operation
spectron copied to clipboard

Spectron: Deprecation Announcement

Open VerteDinde opened this issue 2 years ago • 10 comments

Hey folks! This spring, we posted a warning that Spectron may cease working after Electron 14 (see this pinned issue: #896 ). I wanted to post an official update and announcement:

Beginning in February 2022, Spectron will be officially deprecated by the Electron team.

Why Deprecate Spectron?

Spectron currently has no active maintainers; while we've consistently put out new releases for each new version of Electron, Spectron has had very little maintenance and improvements for well over a year. Spectron now requires a major rewrite to continue working without relying on the external remote module.

We put out a call for community help in the spring, but have unfortunately not received interest in another person maintaining Spectron full-time. Thus, we've decided to deprecate Spectron, rather than leave developers wondering about the future state of the project and possibly dependent on an unsupported project.

Deprecation Timeline

The following is our timeline toward deprecation:

  • November 2021 - January 2022: The Electron team will continue to accept pull requests from the community.
  • January 2022: A final version of announcement warning about Spectron's deprecation will be released.
  • February 1, 2022: This repo will be marked as "archived", and no more pull requests will be accepted.

Following February 1st, 2022, we will continue to leave the Spectron repo up indefinitely, so that others are welcome to fork or use the existing code for their projects. We hope this will help provide a longer transition to any projects that still depend on Spectron.

I would like to maintain/rewrite Spectron!

There has been some discussion about forking and/or rewriting Spectron in the community, including issues like #1044 . We want to encourage that! If you have any interest in maintaining Spectron or contributing to this upstream repo, please respond to this issue.


Thanks all! We appreciate you using Spectron and Electron. 🙇‍♀️ We understand that many of you depend on Spectron for testing your apps, and we want to make this transition as painless for you as possible. If you have any questions or concerns about the deprecation plan, please let us know here.

VerteDinde avatar Nov 02 '21 16:11 VerteDinde

"We want to make this transition as painless for you as possible" - transition to, any recommendations?

suwi avatar Nov 03 '21 10:11 suwi

@suwi transition to "playwright" I guess, see details in #896.

vladimiry avatar Nov 04 '21 16:11 vladimiry

How well does playwright handle different versions of electron? Is there a need for a similar compatibility table as spectron has for different versions of electron?

MasterOdin avatar Nov 04 '21 23:11 MasterOdin

"We want to make this transition as painless for you as possible" - transition to, any recommendations?

Check Playwright doc for Electron support.

I tried Playwright by created a minimal Playwright E2E Testing Sample with CI/CT based on GitHub Actions for Electron App and it seems to work better with the latest electron.

tanshuai avatar Nov 11 '21 10:11 tanshuai

My feedback:

  • Cypress doesn't support Electron anymore, so sadly not an option here. Playwright seems more appropriate, but I've seen test tools come and go in the Electron ecosystem for years...

  • Not 100% sure, but "preinstall": "export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 || set PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1" seems to help avoiding to install unnecessary browsers. It's a tad difficult to set env variables before the package install because you don't have usual solutions such as cross-env, but this one should be cross-platform. It is based on this Stack Overflow question

  • TypeScript works out of the box in Playwright. However at the moment I have trouble with Jest and Playwright typings interacting, when writing tests in TypeScript. I've tried this tip used for Cypress, with no success though: https://stackoverflow.com/questions/58999086/cypress-causing-type-errors-in-jest-assertions

Eventually this seems to work, defining a tsconfig.json at the root of my e2e test folder:

{
    "extends": "../../tsconfig.json",
    "compilerOptions": {
    },
    "exclude": [
        "jest"
    ],
    "include": [
        "./**/*.spec.ts"
    ]
}

But to be confirmed, behaviour can be slightly erratic.

  • It may be tempting to use Jest as the test runner, however @playwright/test is the recommended way

  • The electron.launch command expects your app to be correctly built, you may need to adapt the params (a good practice is to run electron ., which will in turn look for the main file from your package.json).

  • electronApp.firstWindow never ends for me, and electronApp.windows is an empty array. I am using Electron v7, maybe it's too old?

So I am almost there with Playwright but I seem to need a more recent version of Electron for "windows" to be detected as expected. Also I couldn't fix the bad interaction with Jest typings, that are global and clashes with expect.

eric-burel avatar Jan 05 '22 07:01 eric-burel

Update: it does work with Electron v9+, it correctly gets the window from "firstWindow", but not for earlier versions. Which I guess is ok these days for people maintaining apps in the long run.

  • v7 is almost mandatory anyway, because in introduce "invoke"/"handle" to get a decent API and allow to get rid of remote progressively
  • v8, v9 do not have significant breaking change compared to v7, so upgrade path is easy

eric-burel avatar Jan 11 '22 17:01 eric-burel

Hi guys, any idea how to grab dialogs with Playwright Electron? Eg when uploading a file? FileChooser doesn't seem to be the most appropriate, see https://github.com/microsoft/playwright/issues/5013, but the dialog doesn't appear as a window object either.

This package seems to address the issue, but I didn't test it yet: https://github.com/wsw0108/playwright-fake-dialog

I suspect also that keypress events are caught by the browser app but not electron menu, it might require some mocking/programmatic trigger as well. We can couple evaluate and getting the app menu to force triggering relevant actions.

Finally, console.log doesn't work in electronApp.evaluate, that's smth to be careful about when debugging.

eric-burel avatar Jan 25 '22 10:01 eric-burel

@eric-burel Have you had a look into this comment? https://github.com/microsoft/playwright/issues/8278#issuecomment-1009957411

Daveiano avatar Jan 25 '22 11:01 Daveiano

@eric-burel Have you had a look into this comment? microsoft/playwright#8278 (comment)

Yes that's basically the same code. I've managed to make it work with evaluate indeed, that's the goto solution to either mock the main process API or programmatically trigger it

eric-burel avatar Jan 25 '22 12:01 eric-burel

The WebdriverIO community has build a service for WebdriverIO to seamlessly run Electron UI tests in parallel and with all the features WebdriverIO provides. You can find the instructions here. Thanks to @goosewobbler for making this happen!

christian-bromann avatar Feb 22 '22 16:02 christian-bromann