Electron build issues

1. Moved spectron test to a different directory
2. Added a npm command to run spectron test separately
This commit is contained in:
Kiran Niranjan 2017-07-20 17:27:48 +05:30 committed by Kiran Niranjan
parent 4d40bde31a
commit 992bc6649e
11 changed files with 32 additions and 36 deletions

View File

@ -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"
},

View File

@ -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();

View File

@ -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();
});
}
});

View File

@ -1,4 +1,4 @@
const Application = require('./spectron/spectronSetup');
const Application = require('./spectronSetup');
let app = new Application({});
describe('Tests for Bring to front', () => {

View File

@ -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', () => {

View File

@ -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;

View File

@ -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;

View File

@ -0,0 +1,4 @@
{
"testMatch": ["**/*.spectron.js"],
"verbose": true
}

View File

@ -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;

View File

@ -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);
});

View File

@ -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;