Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
describe('runner/suite-runner/stateless-suite-runner', () => {
const sandbox = sinon.sandbox.create();
const suite = util.makeSuiteStub();
const browserAgent = BrowserAgent.create('default-browser');
const runner = new StatelessSuiteRunner(suite, browserAgent);
beforeEach(() => {
sandbox.stub(BrowserAgent.prototype, 'getBrowser');
sandbox.stub(BrowserAgent.prototype, 'freeBrowser');
});
afterEach(() => sandbox.restore());
it('should emit `beginSuite` event', () => {
const onBeginSuite = sinon.spy().named('onBeginSuite');
runner.on('beginSuite', onBeginSuite);
return runner.run()
.then(() => assert.calledOnce(onBeginSuite));
it('should run test in regular test runner', async () => {
const test = makeTest();
const config = makeConfigStub();
const browserAgent = BrowserAgent.create();
const runner = InsistantTestRunner.create(test, config, browserAgent);
const workers = mkWorkers_();
await runner.run(workers);
assert.calledOnceWith(RegularTestRunner.create, test, browserAgent);
assert.calledOnceWith(RegularTestRunner.prototype.run, workers);
});
it('should create insistant test runner for regular test', () => {
sandbox.spy(InsistantTestRunner, 'create');
const test = makeTest();
const config = makeConfigStub();
const browserAgent = BrowserAgent.create();
TestRunner.create(test, config, browserAgent);
assert.calledOnceWith(InsistantTestRunner.create, test, config, browserAgent);
});
});
const mkRunner_ = (opts = {}) => {
const test = opts.test || makeTest({title: 'defaultTest'});
const config = opts.config || makeConfigStub();
const browserId = Object.keys(config.browsers)[0];
const browserAgent = opts.browserAgent || BrowserAgent.create();
browserAgent.browserId = browserId;
return InsistantTestRunner.create(test, config, browserAgent);
};
_runSuite(suite, stateProcessor) {
const browserAgent = BrowserAgent.create(this._browserId, this._browserPool);
const runner = SuiteRunner.create(suite, browserAgent, this._config);
this.passthroughEvent(runner, [
Events.BEGIN_SUITE,
Events.END_SUITE,
Events.SKIP_STATE,
Events.BEGIN_STATE,
Events.END_STATE,
Events.TEST_RESULT,
Events.UPDATE_RESULT,
Events.ERROR,
Events.RETRY
]);
this._suiteRunners.push(runner);
return runner.run(stateProcessor);
const mkRunner_ = (opts = {}) => {
const test = opts.test || makeTest({title: 'defaultTest'});
const browserAgent = opts.browserAgent || BrowserAgent.create();
return RegularTestRunner.create(test, browserAgent);
};
_createMocha() {
const browserAgent = BrowserAgent.create(this._browserId, this._browserPool);
const mocha = MochaAdapter.create(browserAgent, this._config);
eventsUtils.passthroughEvent(mocha, this, [
RunnerEvents.BEFORE_FILE_READ,
RunnerEvents.AFTER_FILE_READ
]);
return mocha.applySkip(this._testSkipper);
}
};
_runSuite(suite, stateProcessor) {
const browserAgent = BrowserAgent.create(this._browserId, this._browserPool);
const runner = SuiteRunner.create(suite, browserAgent, this._config);
this.passthroughEvent(runner, [
Events.BEGIN_SUITE,
Events.END_SUITE,
Events.SKIP_STATE,
Events.BEGIN_STATE,
Events.END_STATE,
Events.TEST_RESULT,
Events.CAPTURE,
Events.UPDATE_RESULT,
Events.WARNING,
Events.ERROR,
Events.RETRY
]);