Open araujoarthur0 opened 10 months ago
I will make a separate PR changing the tests to use node's assert
rather than jest's expect
to make reviewing better here.
I'm converting this to draft, until the tests have been cleared and this can be rebased, ok @araujoarthur0 ?
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. Therequire()
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.