Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue
Closes #1037
Context / Background
The new electron 28 changes things by providing main electron imports through JS modules. That means we'll be able to use
import
syntax rather than node'srequire()
, and no longer need theesm
module to use both notations.The
require()
notation will still be available, making it the best of both worlds for other imports that haven't migrated yet - date-holidays for example.This patch follows #1050 in which I cleaned some things in preparation.
What change is being introduced by this PR?
expect
to node's built-inassert
. Notations differ a bit, but the preferred way is to useassert.strictEqual()
.assert.equal()
seems to be legacy.jest.mock()
to sinon's spies and stubs, which help a lot and have some similar usages.MockClass
object that allows us to mock some files from within. The methods that have to be mocked are diverted before being exported into this class, and it allows us to switch the method to a stub directly from other pieces of code, which switches the method used in other files as well.Spectron
, which is long deprecated. I switched its implementation to use Playwright, which has an Electron module that does pretty much what Spectron did. It is quite flaky though, and the tests work randomly.I am sending this PR as a call for help to finish migrating our tests. We have too much content to migrate and I'll probably take a long time to do it alone.
The way I'm running tests right now is for example
npx electron-mocha .\__tests__\__main__\notification.mjs
.Later on we can change our package.json targets.
How will this be tested?
Hopefully soon by electron-mocha.