From 08ea941b89c44c3e0abf2800525b7ee2372c5819 Mon Sep 17 00:00:00 2001 From: Thamara Andrade Date: Sun, 16 Oct 2022 23:44:21 -0300 Subject: [PATCH] Adding debug messages to mocha tests --- tests/main-window.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/tests/main-window.js b/tests/main-window.js index 8b1f0a7f4..4fffd4bac 100644 --- a/tests/main-window.js +++ b/tests/main-window.js @@ -10,37 +10,51 @@ process.env.NODE_ENV = 'test'; const months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ]; const weekDay = [ 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday' ]; +function log(msg) +{ + console.log(`${(new Date()).toISOString().substr(0, 19)}: ${msg}`); +} + describe('Application launch', function() { - this.timeout(20000); + this.timeout(10000); beforeEach(async function() { this.app = new Application({ path: electronPath, args: [path.join(__dirname, '..')], - waitTimeout: 10000 + waitTimeout: 10000, + quitTimeout: 200 }); + log('Start app...') await this.app.start(); + log('App started.') }); afterEach(async function() { + log(`App is running: ${this.app && this.app.isRunning()}`) if (this.app && this.app.isRunning()) { + log('Stop app...'); await this.app.stop(); + log('App stoped'); } }); it('App opens correctly', async function() { + log('Running test'); const { client, browserWindow } = this.app; await client.waitUntilWindowLoaded(); const title = await browserWindow.getTitle(); assert.equal(title, 'Time to Leave'); + log('Running test - Done'); }); it('Calendar opens on Current Month/Year', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); @@ -48,10 +62,12 @@ describe('Application launch', function() const monthYearText = await monthYear.getText(); const today = new Date(); assert.equal(monthYearText, `${months[today.getMonth()]} ${today.getFullYear()}`); + log('Running test - Done'); }); it('Change to Day View', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); @@ -61,10 +77,12 @@ describe('Application launch', function() const headerDateText = await headerDate.getText(); const today = new Date(); assert.equal(headerDateText, `${weekDay[today.getDay()]}, ${months[today.getMonth()]} ${today.getDate()}, ${today.getFullYear()}`); + log('Running test - Done'); }); it('Calendar change to previous Month', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); @@ -75,10 +93,12 @@ describe('Application launch', function() const today = new Date(); const prevMonthDate = new Date(today.getFullYear(), today.getMonth(), -1); assert.equal(monthYearText, `${months[prevMonthDate.getMonth()]} ${prevMonthDate.getFullYear()}`); + log('Running test - Done'); }); it('Calendar change to next Month', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); @@ -89,10 +109,12 @@ describe('Application launch', function() const today = new Date(); const nextMonthDate = new Date(today.getFullYear(), today.getMonth() + 1, 1); assert.equal(monthYearText, `${months[nextMonthDate.getMonth()]} ${nextMonthDate.getFullYear()}`); + log('Running test - Done'); }); it('Calendar change to pervious Day', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); const switchViewBtn = await client.$('#switch-view'); @@ -104,10 +126,12 @@ describe('Application launch', function() const today = new Date(); const previousDayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() - 1); assert.equal(headerDateText, `${weekDay[previousDayDate.getDay()]}, ${months[previousDayDate.getMonth()]} ${previousDayDate.getDate()}, ${previousDayDate.getFullYear()}`); + log('Running test - Done'); }); it('Calendar change to next Day', async function() { + log('Running test'); const { client } = this.app; await client.waitUntilWindowLoaded(); const switchViewBtn = await client.$('#switch-view'); @@ -119,5 +143,6 @@ describe('Application launch', function() const today = new Date(); const nextDayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate() + 1); assert.equal(headerDateText, `${weekDay[nextDayDate.getDay()]}, ${months[nextDayDate.getMonth()]} ${nextDayDate.getDate()}, ${nextDayDate.getFullYear()}`); + log('Running test - Done'); }); });