Skip to content

Commit

Permalink
add the testRunId property to TestRunErrorFormattableAdapter (closes
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Mar 30, 2020
1 parent 755dd40 commit 34bce8d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/errors/test-run/formattable-adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class TestRunErrorFormattableAdapter {
constructor (err, metaInfo) {
this.userAgent = metaInfo.userAgent;
this.screenshotPath = metaInfo.screenshotPath;
this.testRunId = metaInfo.testRunId;
this.testRunPhase = metaInfo.testRunPhase;

assignIn(this, err);
Expand Down
1 change: 1 addition & 0 deletions src/test-run/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ export default class TestRun extends AsyncEventEmitter {
return new TestRunErrorFormattableAdapter(err, {
userAgent: this.browserConnection.userAgent,
screenshotPath: this.errScreenshotPath || '',
testRunId: this.id,
testRunPhase: this.phase
});
}
Expand Down
29 changes: 29 additions & 0 deletions test/server/test-run-error-formatting-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const expect = require('chai').expect;
const { pull: remove, chain, values } = require('lodash');
const TestRun = require('../../lib/test-run');
const TEST_RUN_PHASE = require('../../lib/test-run/phase');
const { TEST_RUN_ERRORS, RUNTIME_ERRORS } = require('../../lib/errors/types');
const TestRunErrorFormattableAdapter = require('../../lib/errors/test-run/formattable-adapter');
Expand Down Expand Up @@ -118,6 +119,34 @@ function assertErrorMessage (file, err) {

describe('Error formatting', () => {
describe('Errors', () => {
it('Base error formattable adapter properties', () => {
const testRunMock = TestRun.prototype;

Object.assign(testRunMock, {
session: { id: 'test-run-id' },
browserConnection: { userAgent: 'chrome' },
errScreenshotPath: 'screenshot-path',
phase: 'test-run-phase',
callsite: 'callsite',
errs: []
});

TestRun.prototype.addError.call(testRunMock, { callsite: 'callsite' });

const err = testRunMock.errs[0];

expect(err).instanceOf(TestRunErrorFormattableAdapter);

expect(err).eql({
userAgent: 'chrome',
screenshotPath: 'screenshot-path',
testRunId: 'test-run-id',
testRunPhase: 'test-run-phase',
callsite: 'callsite'
});
});


it('Should format "actionIntegerOptionError" message', () => {
assertErrorMessage('action-integer-option-error', new ActionIntegerOptionError('offsetX', '1.01'));
});
Expand Down

0 comments on commit 34bce8d

Please sign in to comment.