diff --git a/lib/worker/runner/test-runner/index.js b/lib/worker/runner/test-runner/index.js index a7475fcfc..35cd3e6ce 100644 --- a/lib/worker/runner/test-runner/index.js +++ b/lib/worker/runner/test-runner/index.js @@ -3,6 +3,7 @@ const HookRunner = require('./hook-runner'); const ExecutionThread = require('./execution-thread'); const OneTimeScreenshooter = require('./one-time-screenshooter'); +const AssertViewError = require('../../../browser/commands/assert-view/errors/assert-view-error'); module.exports = class TestRunner { static create(...args) { @@ -40,9 +41,12 @@ module.exports = class TestRunner { error = error || e; } - hermioneCtx.assertViewResults = hermioneCtx.assertViewResults - ? hermioneCtx.assertViewResults.toRawObject() - : []; + const assertViewResults = hermioneCtx.assertViewResults; + if (assertViewResults && assertViewResults.hasFails()) { + error = new AssertViewError(); + } + + hermioneCtx.assertViewResults = assertViewResults ? assertViewResults.toRawObject() : []; const {meta, changes} = browser; const results = {hermioneCtx, meta, changes}; diff --git a/test/lib/worker/runner/test-runner/index.js b/test/lib/worker/runner/test-runner/index.js index 23d772bfb..19b09d5a1 100644 --- a/test/lib/worker/runner/test-runner/index.js +++ b/test/lib/worker/runner/test-runner/index.js @@ -6,6 +6,8 @@ const HookRunner = require('lib/worker/runner/test-runner/hook-runner'); const ExecutionThread = require('lib/worker/runner/test-runner/execution-thread'); const OneTimeScreenshooter = require('lib/worker/runner/test-runner/one-time-screenshooter'); const BrowserAgent = require('lib/worker/runner/browser-agent'); +const AssertViewError = require('lib/browser/commands/assert-view/errors/assert-view-error'); +const AssertViewResults = require('lib/browser/commands/assert-view/assert-view-results'); const {makeConfigStub} = require('../../../../utils'); const {Suite, Test} = require('../../../_mocha'); @@ -234,9 +236,7 @@ describe('worker/runner/test-runner', () => { }); it('should convert assert view results to raw object', async () => { - const assertViewResults = { - toRawObject: () => [{foo: 'bar'}] - }; + const assertViewResults = AssertViewResults.create([{foo: 'bar'}]); ExecutionThread.create.callsFake(({hermioneCtx}) => { ExecutionThread.prototype.run.callsFake(() => { @@ -251,6 +251,20 @@ describe('worker/runner/test-runner', () => { assert.match(result.hermioneCtx, {assertViewResults: [{foo: 'bar'}]}); }); + it('should fail if assert view results have fails', async () => { + const assertViewResults = AssertViewResults.create([new Error()]); + + ExecutionThread.create.callsFake(({hermioneCtx}) => { + ExecutionThread.prototype.run.callsFake(() => { + hermioneCtx.assertViewResults = assertViewResults; + }); + + return Object.create(ExecutionThread.prototype); + }); + + await assert.isRejected(run_(), AssertViewError); + }); + it('should resolve with browser meta and changes', async () => { ExecutionThread.create.callsFake(({browser}) => { ExecutionThread.prototype.run.callsFake(() => { @@ -291,9 +305,7 @@ describe('worker/runner/test-runner', () => { }); it('should convert assert view results to raw object', async () => { - const assertViewResults = { - toRawObject: () => [{foo: 'bar'}] - }; + const assertViewResults = AssertViewResults.create([{foo: 'bar'}]); ExecutionThread.create.callsFake(({hermioneCtx}) => { ExecutionThread.prototype.run.callsFake(() => {