electron-userland / electron-userland/spectron

Mocking own modules

Open
#151 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.7k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I've got some unit tests covering the auto-updating of my app, but I would also like to test it using Spectron, for example:

- If a users clicks on the "Check for updates" button..
- Is my auto-updater wrapper being called?

I tried to mock my own modules as described here https://github.com/electron/spectron/issues/94 and the mocking works fine, but I can't find a way in my spectron tests to see if the methods of the mock have been called.

I also feel like I'm doing something completely wrong, is a preload script necessary in order to mock your own modules?

--

Spectron is great btw, thanks a lot 💃 :smile: !

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the two Spectron scenarios described in the issue: clicking “Check for updates” and observing the mocked auto-updater wrapper. Read the mocking approach in Spectron issue #94 and compare it with the preload-script question; done means determining whether mocked method calls can be observed from Spectron and documenting the supported setup.

Written by the indexing model from the issue text.

Assessment

Tech stack
electron, javascript
Domain
desktop, testing
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.