From 992bc6649ec958fd9ea88dc8214fe34f9bf374ea Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Thu, 20 Jul 2017 17:27:48 +0530 Subject: [PATCH] Electron build issues 1. Moved spectron test to a different directory 2. Added a npm command to run spectron test separately --- package.json | 3 ++- tests/activityDetection.test.js | 15 +++++---------- .../alwaysOnTop.spectron.js} | 18 +++++++----------- .../bringToFront.spectron.js} | 2 +- .../clipboard.spectron.js} | 4 ++-- .../close.spectron.js} | 2 +- .../full-screen.spectron.js} | 4 ++-- tests/spectron/jest_spectron.json | 4 ++++ .../minimize-on-close.spectron.js} | 4 ++-- .../notificationPosition.spectron.js} | 8 ++++---- .../zoom-in-zoom-out.spectron.js} | 4 ++-- 11 files changed, 32 insertions(+), 36 deletions(-) rename tests/{alwaysOnTop.test.js => spectron/alwaysOnTop.spectron.js} (91%) rename tests/{bringToFront.test.js => spectron/bringToFront.spectron.js} (97%) rename tests/{clipboard.test.js => spectron/clipboard.spectron.js} (96%) rename tests/{close.test.js => spectron/close.spectron.js} (96%) rename tests/{full-screen.test.js => spectron/full-screen.spectron.js} (97%) create mode 100644 tests/spectron/jest_spectron.json rename tests/{minimize-on-close.test.js => spectron/minimize-on-close.spectron.js} (98%) rename tests/{notificationPosition.test.js => spectron/notificationPosition.spectron.js} (97%) rename tests/{zoom-in-zoom-out.test.js => spectron/zoom-in-zoom-out.spectron.js} (98%) diff --git a/package.json b/package.json index 1f01b039..adf2a9fb 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "prebuild": "npm run rebuild && npm run browserify-preload", "browserify-preload": "browserify -o js/preload/_preloadMain.js -x electron --insert-global-vars=__filename,__dirname js/preload/preloadMain.js", "rebuild": "electron-rebuild -f", - "test": "npm run lint && jest --verbose --testPathPattern test --runInBand", + "test": "npm run lint && jest --verbose --testPathPattern test && npm run rebuild && npm run spectron-test", + "spectron-test": "jest --config tests/spectron/jest_spectron.json --runInBand && npm run rebuild", "lint": "eslint --ext .js js/", "rename-exe": "cd dist/win-unpacked && ren Symphony.exe Symphony-Electron.exe" }, diff --git a/tests/activityDetection.test.js b/tests/activityDetection.test.js index 7f38a11a..09d042c0 100644 --- a/tests/activityDetection.test.js +++ b/tests/activityDetection.test.js @@ -3,10 +3,10 @@ const childProcess = require('child_process'); let activityDetection; -describe('Tests for Activity Detection', function() { +describe('Tests for Activity Detection', function () { var originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL; - jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000; + jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000; beforeAll(function (done) { childProcess.exec(`npm rebuild --target=${process.version} --build-from-source`, function (err) { @@ -21,16 +21,11 @@ describe('Tests for Activity Detection', function() { }); afterAll(function (done) { - childProcess.exec('npm run rebuild', function (err, stdout) { - if (err){ - throw(err); - } - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - done(); - }); + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + done(); }); - it('should return null', function() { + it('should return null', function () { activityDetection.setActivityWindow(0, electron.ipcRenderer); const noData = activityDetection.activityDetection(); diff --git a/tests/alwaysOnTop.test.js b/tests/spectron/alwaysOnTop.spectron.js similarity index 91% rename from tests/alwaysOnTop.test.js rename to tests/spectron/alwaysOnTop.spectron.js index f843529f..d007fd56 100644 --- a/tests/alwaysOnTop.test.js +++ b/tests/spectron/alwaysOnTop.spectron.js @@ -1,5 +1,5 @@ -const Application = require('./spectron/spectronSetup'); -const {isMac} = require('../js/utils/misc.js'); +const Application = require('./spectronSetup'); +const {isMac} = require('../../js/utils/misc.js'); const childProcess = require('child_process'); let app = new Application({}); @@ -46,16 +46,12 @@ describe('Tests for Always on top', () => { if (app && app.isRunning()) { jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; app.stop().then(() => { - childProcess.exec('npm run rebuild', function (err, stdout) { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - done(); - }); + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + done(); }).catch((err) => { - childProcess.exec('npm run rebuild', function () { - jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; - expect(err).toBeNull(); - done(); - }); + jasmine.DEFAULT_TIMEOUT_INTERVAL = originalTimeout; + expect(err).toBeNull(); + done(); }); } }); diff --git a/tests/bringToFront.test.js b/tests/spectron/bringToFront.spectron.js similarity index 97% rename from tests/bringToFront.test.js rename to tests/spectron/bringToFront.spectron.js index f9eee252..dbd2363b 100644 --- a/tests/bringToFront.test.js +++ b/tests/spectron/bringToFront.spectron.js @@ -1,4 +1,4 @@ -const Application = require('./spectron/spectronSetup'); +const Application = require('./spectronSetup'); let app = new Application({}); describe('Tests for Bring to front', () => { diff --git a/tests/clipboard.test.js b/tests/spectron/clipboard.spectron.js similarity index 96% rename from tests/clipboard.test.js rename to tests/spectron/clipboard.spectron.js index 98200f89..b06bcab6 100644 --- a/tests/clipboard.test.js +++ b/tests/spectron/clipboard.spectron.js @@ -1,4 +1,4 @@ -const Application = require('./spectron/spectronSetup'); +const Application = require('./spectronSetup'); const path = require('path'); let app = new Application({}); @@ -40,7 +40,7 @@ describe('Tests for clipboard', () => { }); it('should check window count', () => { - return app.client.url('file:///' + path.join(__dirname, '..', 'demo/index.html')); + return app.client.url('file:///' + path.join(__dirname, '..', '..', 'demo/index.html')); }); it('should set the username field', () => { diff --git a/tests/close.test.js b/tests/spectron/close.spectron.js similarity index 96% rename from tests/close.test.js rename to tests/spectron/close.spectron.js index 27ba3a82..6417b28b 100644 --- a/tests/close.test.js +++ b/tests/spectron/close.spectron.js @@ -6,7 +6,7 @@ describe('Tests for Close', () => { let app; beforeAll((done) => { - const Application = require('./spectron/spectronSetup'); + const Application = require('./spectronSetup'); app = new Application({}); return app.startApplication().then((startedApp) => { app = startedApp; diff --git a/tests/full-screen.test.js b/tests/spectron/full-screen.spectron.js similarity index 97% rename from tests/full-screen.test.js rename to tests/spectron/full-screen.spectron.js index f62f4e11..1e71ca56 100644 --- a/tests/full-screen.test.js +++ b/tests/spectron/full-screen.spectron.js @@ -1,8 +1,8 @@ const path = require('path'); const fs = require('fs'); const childProcess = require('child_process'); -const Application = require('./spectron/spectronSetup'); -const {isMac} = require('../js/utils/misc'); +const Application = require('./spectronSetup'); +const {isMac} = require('../../js/utils/misc'); let robot; let configPath; diff --git a/tests/spectron/jest_spectron.json b/tests/spectron/jest_spectron.json new file mode 100644 index 00000000..abd4d921 --- /dev/null +++ b/tests/spectron/jest_spectron.json @@ -0,0 +1,4 @@ +{ + "testMatch": ["**/*.spectron.js"], + "verbose": true +} diff --git a/tests/minimize-on-close.test.js b/tests/spectron/minimize-on-close.spectron.js similarity index 98% rename from tests/minimize-on-close.test.js rename to tests/spectron/minimize-on-close.spectron.js index 9925bb4e..f07d3f5f 100644 --- a/tests/minimize-on-close.test.js +++ b/tests/spectron/minimize-on-close.spectron.js @@ -1,8 +1,8 @@ const path = require('path'); const fs = require('fs'); const childProcess = require('child_process'); -const Application = require('./spectron/spectronSetup'); -const {isMac} = require('../js/utils/misc'); +const Application = require('./spectronSetup'); +const {isMac} = require('../../js/utils/misc'); let robot; let configPath; diff --git a/tests/notificationPosition.test.js b/tests/spectron/notificationPosition.spectron.js similarity index 97% rename from tests/notificationPosition.test.js rename to tests/spectron/notificationPosition.spectron.js index 8ebe2456..4a5dc8ce 100644 --- a/tests/notificationPosition.test.js +++ b/tests/spectron/notificationPosition.spectron.js @@ -1,6 +1,6 @@ -const Application = require('./spectron/spectronSetup'); +const Application = require('./spectronSetup'); const path = require('path'); -const {isMac} = require('../js/utils/misc'); +const {isMac} = require('../../js/utils/misc'); let app = new Application({}); describe('Tests for Notification position', () => { @@ -45,9 +45,9 @@ describe('Tests for Notification position', () => { it('should load demo html page', () => { let filePath; if (process.platform === 'win32') { - filePath = 'file:///' + path.join(__dirname, '..', 'demo/index.html'); + filePath = 'file:///' + path.join(__dirname, '..', '..', 'demo/index.html'); } else { - filePath = 'file://$(pwd)/' + path.join(__dirname, '..', 'demo/index.html') + filePath = 'file://$(pwd)/' + path.join(__dirname, '..', '..', 'demo/index.html') } return app.client.url(filePath); }); diff --git a/tests/zoom-in-zoom-out.test.js b/tests/spectron/zoom-in-zoom-out.spectron.js similarity index 98% rename from tests/zoom-in-zoom-out.test.js rename to tests/spectron/zoom-in-zoom-out.spectron.js index 4585b0f2..c9840c3b 100644 --- a/tests/zoom-in-zoom-out.test.js +++ b/tests/spectron/zoom-in-zoom-out.spectron.js @@ -1,8 +1,8 @@ const path = require('path'); const fs = require('fs'); const childProcess = require('child_process'); -const Application = require('./spectron/spectronSetup'); -const {isMac} = require('../js/utils/misc'); +const Application = require('./spectronSetup'); +const {isMac} = require('../../js/utils/misc'); let robot; let configPath;