Skip to content
Merged
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
fix(hermione gui): do not show disabled and silently skipped tests
  • Loading branch information
DudaGod committed Jul 10, 2018
commit cf45d11d88497a5aaa6e53aaf613feb5bc406414
4 changes: 4 additions & 0 deletions lib/gui/tool-runner-factory/hermione/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ module.exports = class HermioneRunner extends BaseToolRunner {

_handleRunnableCollection() {
this._collection.eachTest((test, browserId) => {
if (test.disabled || test.silentSkip) {
return;
}

const testId = formatId(test.id(), browserId);
this._tests[testId] = _.extend(test, {browserId});

Expand Down
99 changes: 99 additions & 0 deletions test/lib/gui/tool-runner-factory/hermione/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
'use strict';

const _ = require('lodash');
const proxyquire = require('proxyquire');
const ReportBuilder = require('lib/report-builder-factory/report-builder');
const {stubTool} = require('test/utils');

describe('lib/gui/tool-runner-factory/hermione/index', () => {
const sandbox = sinon.createSandbox();
let reportBuilder;
let ToolGuiReporter;

const mkTestCollection_ = (testsTree = {}) => {
return {eachTest: (cb) => _.forEach(testsTree, cb)};
};

const stubTest_ = (opts) => {
return _.defaults(opts, {id: () => 'default-id'});
};

const mkToolCliOpts_ = (globalCliOpts = {name: () => 'hermione'}, guiCliOpts = {}) => {
return {program: globalCliOpts, options: guiCliOpts};
};
const mkPluginConfig_ = (config = {}) => {
const pluginConfig = _.defaults(config, {path: 'default-path'});
return {pluginConfig};
};

const initGuiReporter = (hermione, opts = {}) => {
opts = _.defaults(opts, {
paths: [],
configs: {}
});

const configs = _.defaults(opts.configs, mkToolCliOpts_(), mkPluginConfig_());

return ToolGuiReporter.create(opts.paths, hermione, configs);
};

beforeEach(() => {
reportBuilder = sinon.createStubInstance(ReportBuilder);
sandbox.stub(ReportBuilder, 'create').returns(reportBuilder);
reportBuilder.getResult.returns({});

ToolGuiReporter = proxyquire(`lib/gui/tool-runner-factory/hermione`, {
'./report-subscriber': sandbox.stub()
});
});

afterEach(() => sandbox.restore());

describe('initialize', () => {
it('should not add disabled test to report', () => {
const hermione = stubTool();
hermione.readTests.resolves(mkTestCollection_({bro: stubTest_({disabled: true})}));

const gui = initGuiReporter(hermione, {paths: ['foo']});

return gui.initialize()
.then(() => {
assert.notCalled(reportBuilder.addSkipped);
assert.notCalled(reportBuilder.addIdle);
});
});

it('should not add silently skipped test to report', () => {
const hermione = stubTool();
hermione.readTests.resolves(mkTestCollection_({bro: stubTest_({silentSkip: true})}));

const gui = initGuiReporter(hermione, {paths: ['foo']});

return gui.initialize()
.then(() => {
assert.notCalled(reportBuilder.addSkipped);
assert.notCalled(reportBuilder.addIdle);
});
});

it('should add skipped test to report', () => {
const hermione = stubTool();
hermione.readTests.resolves(mkTestCollection_({bro: stubTest_({pending: true})}));

const gui = initGuiReporter(hermione, {paths: ['foo']});

return gui.initialize()
.then(() => assert.calledOnce(reportBuilder.addSkipped));
});

it('should add idle test to report', () => {
const hermione = stubTool();
hermione.readTests.resolves(mkTestCollection_({bro: stubTest_()}));

const gui = initGuiReporter(hermione, {paths: ['foo']});

return gui.initialize()
.then(() => assert.calledOnce(reportBuilder.addIdle));
});
});
});