How to use gemini-core - 10 common examples

To help you get started, we’ve selected a few gemini-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gemini-testing / gemini / lib / passthrough-emitter.js View on Github external
'use strict';

const _ = require('lodash'),
    AsyncEmitter = require('gemini-core').events.AsyncEmitter;

module.exports = class PassthroughEmitter extends AsyncEmitter {
    // Allow to pass only one argument with event
    emit(type, data) {
        return super.emit(type, data);
    }

    emitAndWait(type, data) {
        return super.emitAndWait(type, data, {shouldWait: true});
    }

    /**
     * Emit event emitted by emitter
     * @param {EventEmitter} emitter
     * @param {String|String[]} event or array of events to passthrough
     */
github gemini-testing / hermione / test / lib / worker / hermione-facade.js View on Github external
beforeEach(() => {
        ipc = new AsyncEmitter();
        HermioneFacade = proxyquire('lib/worker/hermione-facade', {
            // TODO: think about how to make it easier
            '../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)}
        });

        config = makeConfigStub();

        hermione = Object.assign(new AsyncEmitter(), {
            init: sandbox.spy().named('hermioneInit'),
            config
        });
        sandbox.stub(Hermione, 'create').returns(hermione);

        ipc.on('worker.init', () => {
            process.nextTick(() => ipc.emit('master.init'));
        });
github gemini-testing / hermione / test / lib / worker / hermione-facade.js View on Github external
beforeEach(() => {
        ipc = new AsyncEmitter();
        HermioneFacade = proxyquire('lib/worker/hermione-facade', {
            // TODO: think about how to make it easier
            '../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)}
        });

        config = makeConfigStub();

        hermione = Object.assign(new AsyncEmitter(), {
            init: sandbox.spy().named('hermioneInit'),
            config
        });
        sandbox.stub(Hermione, 'create').returns(hermione);

        ipc.on('worker.init', () => {
            process.nextTick(() => ipc.emit('master.init'));
        });
        ipc.on('worker.syncConfig', () => {
            process.nextTick(() => ipc.emit('master.syncConfig', {config}));
        });
    });
github gemini-testing / hermione / test / lib / worker / hermione-facade.js View on Github external
'use strict';

const proxyquire = require('proxyquire');
const {AsyncEmitter} = require('gemini-core').events;
const Hermione = require('lib/worker/hermione');
const {makeConfigStub} = require('../../utils');

describe('worker/hermione-facade', () => {
    const sandbox = sinon.createSandbox();
    let HermioneFacade;
    let hermione;
    let config;
    let ipc;

    beforeEach(() => {
        ipc = new AsyncEmitter();
        HermioneFacade = proxyquire('lib/worker/hermione-facade', {
            // TODO: think about how to make it easier
            '../utils/ipc': {on: ipc.on.bind(ipc), emit: ipc.emit.bind(ipc)}
        });
github gemini-testing / gemini / test / unit / runner / browser-runner / index.js View on Github external
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));
        });
github gemini-testing / gemini / test / unit / runner / browser-runner / index.js View on Github external
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]
                    );
                });
        });
github gemini-testing / gemini / test / unit / runner / browser-runner / index.js View on Github external
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));
        });
github gemini-testing / hermione / test / lib / runner / test-runner / regular-test-runner.js View on Github external
it('should be emitted even on browser get fail', async () => {
                const onTestBegin = sinon.stub().named('onTestBegin');
                const runner = mkRunner_()
                    .on(Events.TEST_BEGIN, onTestBegin);

                BrowserAgent.prototype.getBrowser.rejects();

                await run_({runner});

                assert.calledOnce(onTestBegin);
            });
        });
github gemini-testing / hermione / test / lib / runner / test-runner / insistant-test-runner.js View on Github external
it('should create test runner with high priority browser agent', async () => {
                    onFirstTestRun_((innerRunner) => innerRunner.emit(Events.TEST_FAIL, makeFailedTest_()));

                    const browserAgent = Object.create(BrowserAgent.prototype);
                    const highPriorityBrowserAgent = Object.create(HighPriorityBrowserAgent.prototype);
                    HighPriorityBrowserAgent.create
                        .withArgs(browserAgent).returns(highPriorityBrowserAgent);
                    const runner = mkRunnerWithRetries_({browserAgent});

                    await run_({runner});

                    assert.calledWith(RegularTestRunner.create, sinon.match.any, highPriorityBrowserAgent);
                });
github gemini-testing / gemini / test / unit / runner / suite-runner / stateless-suite-runner.js View on Github external
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));