Skip to content

Instantly share code, notes, and snippets.

@jkrems
Last active September 10, 2015 00:31
Show Gist options
  • Save jkrems/6d172d355a38d1290d53 to your computer and use it in GitHub Desktop.
Save jkrems/6d172d355a38d1290d53 to your computer and use it in GitHub Desktop.

Manual linking together of -wd and -core:

import initTestium from 'testium-core';
import createDriver from 'testium-driver-wd';
import {test} from 'tap';

test('my test', async t => {
  let b = await initTestium().then(createDriver);
  await b.navigateTo('/foo');
  t.equal(await b.getTitle(), 'Hello World', 'shows the right title');
});

Same, but -sync instead of -wd:

import initTestium from 'testium-core';
import createDriver from 'testium-driver-sync';
import {test} from 'tap';

test('my test', async t => {
  let b = await initTestium().then(createDriver);
  b.navigateTo('/foo');
  t.equal(b.getTitle(), 'Hello World');
});

Using -mocha and explict driver library:

import injectBrowser from 'testium-mocha';
import createDriver from 'testium-driver-sync';
import assert from 'assertive';

describe('my feature', () => {
  before(injectBrowser({ driver: createDriver }));

  before(() => {
    this.browser.navigateTo('/foo');
  });

  it('shows the right title', () => {
    assert.equal('Hello World', this.browser.getTitle());
  });
});

Using -mocha and automatic driver loading:

import injectBrowser from 'testium-mocha';
import assert from 'assertive';

describe('my feature', () => {
  before(injectBrowser({ driver: 'sync' }));

  before(() => {
    this.browser.navigateTo('/foo');
  });

  it('shows the right title', () => {
    assert.equal('Hello World', this.browser.getTitle());
  });
});

Using -tap and automatic driver loading:

import test from 'testium-tap';

test('my feature', { driver: 'wd' }, async (t, browser) => {
  await browser.navigateTo('/foo');
  t.equal(await b.getTitle(), 'Hello World', 'shows the right title');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment