diff --git a/lib/reporter/results.js b/lib/reporter/results.js index ed700d8d0a..15a9807bb5 100644 --- a/lib/reporter/results.js +++ b/lib/reporter/results.js @@ -1,5 +1,5 @@ const AssertionError = require('assertion-error'); -const {merge: lodashMerge} = require('lodash'); +const lodashMerge = require('lodash.merge'); const Utils = require('../utils'); const {Logger} = Utils; diff --git a/test/extra/commands/customCommandAppendResults.js b/test/extra/commands/customCommandAppendResults.js new file mode 100644 index 0000000000..86535ea5ac --- /dev/null +++ b/test/extra/commands/customCommandAppendResults.js @@ -0,0 +1,14 @@ +module.exports = class AppendResult { + command() { + const {name} = this.client.reporter.currentTest; + const {testResults} = this.client.reporter; + testResults.appendTestResult({ + [name]: { + customReport: { + success: true + } + } + }); + + } +}; \ No newline at end of file diff --git a/test/sampletests/appendtestresult/sampleWithAppendResults.js b/test/sampletests/appendtestresult/sampleWithAppendResults.js new file mode 100644 index 0000000000..65fa3a4c54 --- /dev/null +++ b/test/sampletests/appendtestresult/sampleWithAppendResults.js @@ -0,0 +1,5 @@ +module.exports = { + demoTest(client) { + client.url('http://localhost').customCommandAppendResults().end(); + } +}; \ No newline at end of file diff --git a/test/src/runner/testReporter.js b/test/src/runner/testReporter.js index e0627fb27a..96c62b6cba 100644 --- a/test/src/runner/testReporter.js +++ b/test/src/runner/testReporter.js @@ -329,4 +329,39 @@ describe('testReporter', function() { assert.strictEqual(possibleError, null); }); + + it('check reporter output with appended results', async function() { + let possibleError = null; + const testPath = [path.join(__dirname, '../../sampletests/appendtestresult/sampleWithAppendResults.js')]; + const customCommands = [path.join(__dirname, '../../extra/commands')]; + + try { + await runTests({ + source: testPath + }, settings({ + custom_commands_path: customCommands, + globals: { + waitForConditionPollInterval: 20, + waitForConditionTimeout: 50, + retryAssertionTimeout: 50, + reporter: function (results) { + const module = results.modules['sampleWithAppendResults']; + + assert.ok(Object.keys(module).includes('completedSections')); + const completedSections = module['completedSections']; + assert.ok(Object.keys(completedSections).includes('demoTest')); + + const test = completedSections['demoTest']; + assert.ok(Object.keys(test).includes('customReport')); + assert.deepStrictEqual(test.customReport, {success: true}); + } + }, + silent: true, + output: false + })); + } catch (err) { + possibleError = err; + } + assert.strictEqual(possibleError, null); + }); });