Skip to content

Commit

Permalink
Merge pull request #179 from gemini-testing/fix/grep
Browse files Browse the repository at this point in the history
fix: option 'grep' fails running of test with exception
  • Loading branch information
j0tunn authored Sep 8, 2017
2 parents 7da2034 + 4c80583 commit e4526c7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/worker/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ exports.init = (testFiles, configPath, cb) => {
};

exports.syncConfig = (config, cb) => {
delete config.system.mochaOpts.grep; // grep affects only master

hermione.config.mergeWith(config);

cb();
Expand Down
34 changes: 26 additions & 8 deletions test/lib/worker/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict';

const _ = require('lodash');
const q = require('q');
const Config = require('../../../lib/config');
const worker = require('../../../lib/worker');
Expand Down Expand Up @@ -55,26 +56,43 @@ describe('worker', () => {
});

describe('syncConfig', () => {
const stubConfig = (opts) => _.defaults(opts || {}, {mergeWith: sandbox.stub(), system: {mochaOpts: {}}});
const syncConfig = (config, cb) => {
worker.init(null, null, () => {});
worker.syncConfig(config, cb || (() => {}));
};

it('should sync passed config with a config of inited hermione', () => {
const config = {mergeWith: sandbox.stub()};
const config = stubConfig();

Config.create.returns(config);

worker.init(null, null, () => {});
worker.syncConfig({some: 'config'}, () => {});
syncConfig(stubConfig({some: 'config'}));

assert.calledOnceWith(config.mergeWith, {some: 'config'});
assert.calledOnce(config.mergeWith);
assert.calledWithMatch(config.mergeWith, {some: 'config'});
});

it('should sync all mocha opts except grep', () => {
const config = stubConfig();

Config.create.returns(config);

syncConfig({system: {mochaOpts: {grep: 'foo', timeout: 10}}});

assert.deepEqual(
config.mergeWith.firstCall.args[0],
{system: {mochaOpts: {timeout: 10}}}
);
});

it('should call callback after merge', () => {
const cb = sandbox.spy().named('cb');
const config = {mergeWith: sandbox.stub()};
const config = stubConfig();

Config.create.returns(config);

worker.init(null, null, () => {});

worker.syncConfig({some: 'config'}, cb);
syncConfig(stubConfig(), cb);

assert.callOrder(config.mergeWith, cb);
});
Expand Down

0 comments on commit e4526c7

Please sign in to comment.