Skip to content

Instantly share code, notes, and snippets.

@senocular
Created October 31, 2016 20:12
Show Gist options
  • Save senocular/c5b015a0f7c77fa934fb7ba1f5973368 to your computer and use it in GitHub Desktop.
Save senocular/c5b015a0f7c77fa934fb7ba1f5973368 to your computer and use it in GitHub Desktop.
Hooks before/beforeEach continues to running test(s) before their command queue is finished.

Hooks before/beforeEach continues to running test(s) before their command queue is finished.

When running commands without an async done callback in a before and/or beforeEach, the next test is run before the command queue within the before/beforeEach is complete.

module.exports = {
    beforeEach: function (browser) { // or before
        browser.pause(1000, function() {
            console.log('beforeEach pause complete')
        })
    },

    test: function (browser) {
        console.log('test started');
    }
};

// Actual output:
// 'test started'
// 'beforeEach pause complete'

// Expected output:
// 'beforeEach pause complete'
// 'test started'

Workaround: use the async hook format: beforeEach (browser, done), calling done() at the end of the command queue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment