tempus icon indicating copy to clipboard operation
tempus copied to clipboard

Add unit tests

Open KeziahMoselle opened this issue 4 years ago • 9 comments

https://electronjs.org/spectron https://github.com/testing-library/react-testing-library

Tests that needs to be written : Test cases

KeziahMoselle avatar Oct 11 '19 17:10 KeziahMoselle

I've forked, cloned and ran the application (nice work By the way!) and will implement some react unit tests for you.

ghost avatar Oct 12 '19 03:10 ghost

I'm glad you like it ! Thank you ! If you have any question don't hesitate to ask them :D

KeziahMoselle avatar Oct 12 '19 08:10 KeziahMoselle

Hi there! After getting everything setup, and calling a render() function from a test, I am getting an error regarding the electron API:

TypeError: Cannot read property 'on' of undefined

  36 | 
  37 |     // Listeners from the Tray menu
> 38 |     window.ipcRenderer.on('start', () => {
     |                        ^
  39 |       if (this.state.state === '') {
  40 |         this.start()
  41 |       } else {

I've tried importing the ipcRenderer into the react files and I can't seem to find any other supporting documentation on using the react-testing-library w/ electron. Do you know of other projects that have used the two frameworks together? I'm going to give it another investigation in a little bit, but thought I'd check with you as well.

ghost avatar Oct 12 '19 23:10 ghost

Maybe we can use this : Spectron ? Also there is a complete boilerplate that uses Jest and React Testing Library, maybe we can get some inspiration from there https://github.com/react-boilerplate/react-boilerplate

KeziahMoselle avatar Oct 12 '19 23:10 KeziahMoselle

Oh sweet! It looks like that will solve our problem! I can boot up the app with spectron and it looks like I can even use selenium within that (which is what I use at work). I could probably do quite a bit of testing for you too since I have experience with selenium. I'll send a PR with the basic framework and then continue building it out after that. thanks!

ghost avatar Oct 12 '19 23:10 ghost

Nice ! Thank you so much :smile:

KeziahMoselle avatar Oct 12 '19 23:10 KeziahMoselle

Managed to make it work ! preview

This is being worked on #79

KeziahMoselle avatar Oct 27 '19 17:10 KeziahMoselle

Dude! Nice work! If i can i'll try to get it running on my machine again. I have become very busy at work though, so no guarantees! But well done again!!

ghost avatar Oct 31 '19 03:10 ghost

Thank's ! I don't have access to the Electron module for the tests in src so it's only to test the logic of the app and in public it have access to the modules but it still needs some configuration !

KeziahMoselle avatar Oct 31 '19 10:10 KeziahMoselle