Edit on GitHub

Promise Chain Mixins

Testium’s promise chain mixins are a thin wrapper around wd.addPromiseChainMethod.

Example: browser.login()

The Mixin File

Create a file test/mixins/login.js with the following content:

exports.login = function login() {
  return this.loadPage('/login')
    .type('.username', 'test')
    .type('.password', 'passw0rd')

Every export of the file will be turned into a method on browser. When called, this will refer to the browser.

Add Config

Edit (or create) .testiumrc in the project directory:

; [other settings...]

; This path will be resolved relative to the project directory
wd[] = ./test/mixins/login.js

If you prefer JSON for .testiumrc:

  "mixins": {
    "wd": ["./test/mixins/login.js"]

Using the Helper

In test files you can now start using browser.login:

// ...
before(() => browser.login());

before(() => browser.loadPage('/account'));

it("shows the test user's account", () => { /* ... */ });