Merge pull request #499 from embark-framework/dont_continue_on_errors

Fix tests error reporting when there are deployment errors
This commit is contained in:
Iuri Matias 2018-06-08 13:02:13 -04:00 committed by GitHub
commit aff1dabb3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 7 deletions

View File

@ -83,8 +83,8 @@ module.exports = {
mocha.suite.timeout(0);
mocha.suite.beforeAll('Wait for deploy', (done) => {
global.embark.onReady(() => {
done();
global.embark.onReady((err) => {
done(err);
});
});

View File

@ -33,6 +33,7 @@ class Test {
this.contracts = {};
this.events = new Events();
this.ready = true;
this.error = false;
this.builtContracts = {};
this.compiledContracts = {};
@ -111,12 +112,28 @@ class Test {
}
onReady(callback) {
const self = this;
if (this.ready) {
return callback();
}
this.events.once('ready', () => {
if (this.error) {
return callback(this.error);
}
let errorCallback, readyCallback;
errorCallback = (err) => {
self.events.removeListener('ready', readyCallback);
callback(err);
};
readyCallback = () => {
self.events.removeListener('deployError', errorCallback);
callback();
});
};
this.events.once('ready', readyCallback);
this.events.once('deployError', errorCallback);
}
config(options, callback) {
@ -175,12 +192,14 @@ class Test {
},
function deploy(next) {
self._deploy(options, (err, accounts) => {
self.ready = true;
self.events.emit('ready');
if (err) {
console.error(err.red);
self.events.emit('deployError', err);
self.error = err;
return next(err);
}
self.ready = true;
self.error = false;
self.events.emit('ready');
next(null, accounts);
});
}