Skip to content

feat: add 'skipReason' for 'success' and 'fail' events #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions lib/collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ module.exports = class Collector {
}

addSuccess(result) {
this._addTestResult(result, {status: 'success'});
this._addTestResult(result, {
status: 'success',
skipReason: this._toolCollector.getSkipReason(result)
});
}

addFail(result) {
Expand All @@ -27,14 +30,15 @@ module.exports = class Collector {
this._addTestResult(result, {
status: 'fail',
errorReason: {message, stack},
retries: [{message, stack}]
retries: [{message, stack}],
skipReason: this._toolCollector.getSkipReason(result)
});
}

addSkipped(result) {
this._addTestResult(result, {
status: 'skipped',
skipReason: this._toolCollector.getSkipReason(result)
skipReason: this._toolCollector.getSkipReason(result, 'No skip reason')
});
}

Expand All @@ -48,7 +52,8 @@ module.exports = class Collector {
this._addTestResult(result, {
status: 'error',
errorReason: {message, stack},
retries: [{message, stack}]
retries: [{message, stack}],
skipReason: this._toolCollector.getSkipReason(result)
});
}

Expand Down
4 changes: 2 additions & 2 deletions lib/collector/tool/hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ exports.configureTestResult = (result) => {
return testResult;
};

exports.getSkipReason = (result) => {
exports.getSkipReason = (result, reason) => {
const findSkipReason = (test) => test.parent && findSkipReason(test.parent) || test.skipReason;

return findSkipReason(result) || 'No skip reason';
return findSkipReason(result) || reason;
};
45 changes: 42 additions & 3 deletions test/lib/collector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,24 @@ describe('collector/index', () => {
'some name.bro': {
fullName: 'some name',
browserId: 'bro',
status: 'success'
status: 'success',
skipReason: undefined
}});
});
});

it('should add succesfully passed test with skip reason', () => {
const data = {fullName: 'some name', browserId: 'bro'};
const collector = mkCollector_({
getSkipReason: sandbox.stub().returns('some-reason')
});

collector.addSuccess(data);

return saveReport_(collector)
.then((result) => assert.include(result['some name.bro'], {skipReason: 'some-reason'}));
});

it('should add failed test', () => {
const testError = new Promise.OperationalError('test');
const data = {fullName: 'some name', browserId: 'bro', err: testError};
Expand All @@ -84,11 +97,24 @@ describe('collector/index', () => {
browserId: 'bro',
status: 'fail',
errorReason: {message: testError.message, stack: testError.stack},
retries: [{message: testError.message, stack: testError.stack}]
retries: [{message: testError.message, stack: testError.stack}],
skipReason: undefined
}});
});
});

it('should add failed test with skip reason', () => {
const data = {fullName: 'some name', browserId: 'bro', err: new Promise.OperationalError('test')};
const collector = mkCollector_({
getSkipReason: sandbox.stub().returns('some-reason')
});

collector.addFail(data);

return saveReport_(collector)
.then((result) => assert.include(result['some name.bro'], {skipReason: 'some-reason'}));
});

it('should add skipped test', () => {
const data = {fullName: 'some name', browserId: 'bro'};
const collector = mkCollector_({
Expand Down Expand Up @@ -120,7 +146,8 @@ describe('collector/index', () => {
browserId: 'bro',
status: 'fail',
errorReason: {message: testError.message, stack: testError.stack},
retries: [{message: testError.message, stack: testError.stack}]
retries: [{message: testError.message, stack: testError.stack}],
skipReason: undefined
}});
});
});
Expand All @@ -144,6 +171,18 @@ describe('collector/index', () => {
return saveReport_(collector)
.then((result) => assert.deepPropertyVal(result['some name.bro'], 'errorReason.stack', 'stack-msg'));
});

it('should add errored test with skip reason', () => {
const data = {fullName: 'some name', browserId: 'bro'};
const collector = mkCollector_({
getSkipReason: sandbox.stub().returns('some-reason')
});

collector.addError(data);

return saveReport_(collector)
.then((result) => assert.include(result['some name.bro'], {skipReason: 'some-reason'}));
});
});

describe('saveFile', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/lib/collector/tool/hermione.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('collector/tool/hermione', () => {

describe('getSkipReason', () => {
it('should return default skip reason if "skipReason" is not specified', () => {
assert.strictEqual(hermioneToolCollector.getSkipReason({}), 'No skip reason');
assert.strictEqual(hermioneToolCollector.getSkipReason({}, 'No skip reason'), 'No skip reason');
});

it('should return skip reason from test result', () => {
Expand Down