split protractor configuration file (#4983)

This commit is contained in:
Eugenio Romano
2019-08-09 07:51:04 +01:00
committed by GitHub
parent ab2fc2fb15
commit dfbefa2ce5
6 changed files with 451 additions and 388 deletions

View File

@@ -0,0 +1,112 @@
function beforeAllRewrite() {
const originalBeforeAll = global.beforeAll;
// tslint:disable-next-line
global.beforeAll = function (beforeAllFunction, timeout) {
const wrapClbk = async (done) => {
try {
await beforeAllFunction(done);
} catch (error) {
console.log('Error Before all second attempt in 10 sec');
sleep(10000);
try {
await beforeAllFunction(done);
} catch (e) {
// tslint:disable-next-line:no-console
console.log('Error Before all second attempt fail all' + JSON.stringify(error));
expect(true).toBe(false);
}
}
done();
return;
};
originalBeforeAll(wrapClbk, timeout);
};
};
function afterAllRewrite() {
const originalAfterAll = global.afterAll;
// tslint:disable-next-line
global.afterAll = function (afterAllFunction, timeout) {
const wrapClbk = async (done) => {
try {
await afterAllFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error After all' + JSON.stringify(error));
}
done();
return;
};
originalAfterAll(wrapClbk, timeout);
};
};
function beforeEachAllRewrite() {
const originalBeforeEach = global.beforeEach;
// tslint:disable-next-line
global.beforeEach = function (beforeEachFunction, timeout) {
const wrapClbk = async (done) => {
try {
await beforeEachFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error before Each' + JSON.stringify(error));
expect(true).toBe(false);
}
done();
return;
};
originalBeforeEach(wrapClbk, timeout);
};
};
function afterEachAllRewrite() {
const originalAfterEach = global.afterEach;
// tslint:disable-next-line
global.afterEach = function (afterEachFunction, timeout) {
const wrapClbk = async (done) => {
try {
await afterEachFunction(done);
} catch (error) {
// tslint:disable-next-line:no-console
console.log('Error After each' + JSON.stringify(error));
}
done();
return;
};
originalAfterEach(wrapClbk, timeout);
};
};
function sleep(delay) {
var start = new Date().getTime();
while (new Date().getTime() < start + delay) ;
}
module.exports = {
beforeAllRewrite: beforeAllRewrite,
afterAllRewrite: afterAllRewrite,
beforeEachAllRewrite: beforeEachAllRewrite,
afterEachAllRewrite: afterEachAllRewrite
};