Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should pass to suite runner browser agent associated with current browser', () => {
const browserAgent = new BrowserAgent('browser');
const suiteCollection = new SuiteCollection([makeSuiteStub({browsers: ['browser']})]);
sandbox.stub(BrowserAgent, 'create');
BrowserAgent.create.returns(browserAgent);
const runner = mkRunner_('browser');
return runner.run(suiteCollection)
.then(() => assert.calledWith(suiteRunnerFabric.create, sinon.match.any, browserAgent));
});
it('should create browser agent instance for each suite', () => {
const suiteCollection = new SuiteCollection([
makeSuiteStub({browsers: ['bro']}),
makeSuiteStub({browsers: ['bro']})
]);
sandbox.spy(BrowserAgent, 'create');
return mkRunner_('bro')
.run(suiteCollection)
.then(() => {
assert.calledTwice(BrowserAgent.create);
assert.notEqual(
suiteRunnerFabric.create.firstCall.args[1],
suiteRunnerFabric.create.secondCall.args[1]
);
});
});
it('should pass to suite runner browser agent associated with current browser', () => {
const browserAgent = new BrowserAgent('browser');
const suiteCollection = new SuiteCollection([makeSuiteStub({browsers: ['browser']})]);
sandbox.stub(BrowserAgent, 'create');
BrowserAgent.create.returns(browserAgent);
const runner = mkRunner_('browser');
return runner.run(suiteCollection)
.then(() => assert.calledWith(suiteRunnerFabric.create, sinon.match.any, browserAgent));
});
const mkRunner_ = (suite, browserId) => {
suite = suite || util.makeSuiteStub();
const browserAgent = new BrowserAgent();
browserAgent.browserId = browserId || 'default-browser';
return new SkippedSuiteRunner(suite, browserAgent);
};
beforeEach(() => {
sandbox.stub(BrowserAgent, 'create');
sandbox.stub(SingleTestMochaAdapter, 'create').returns({tests: []});
sandbox.stub(MochaAdapter, 'prepare');
sandbox.stub(MochaAdapter, 'create').callsFake(() => mkMochaAdapterStub_());
sandbox.stub(MochaAdapter.prototype, 'applySkip').returnsThis();
sandbox.stub(MochaAdapter.prototype, 'loadFiles');
});
const createMochaRunner_ = () => {
return new MochaRunner(
'bro',
makeConfigStub({browsers: ['bro']}),
sinon.createStubInstance(BrowserAgent),
sinon.createStubInstance(TestSkipper)
);
};
const mkRunner_ = (suite, browserId) => {
const browserAgent = new BrowserAgent();
browserAgent.browserId = browserId || browser.id;
return RegularSuiteRunner.create(
suite || makeSuiteStub(),
browserAgent
);
};
const mkBrowserAgentStub_ = (browserId) => {
const browserAgent = new BrowserAgent();
browserAgent.browserId = browserId || 'default-bro';
return browserAgent;
};