testing-library / webdriverio-testing-library

🕷️ Simple and complete WebdriverIO DOM testing utilities that encourage good testing practices.
17 stars 14 forks source link

setupBrowser to be initialized in the hooks #14

Closed suchitrak closed 3 years ago

suchitrak commented 3 years ago

Where should setupBrowser be invoked. Currently I am using it like below and it works perfectly. `const { When, Then } = require('cucumber'); const debugModule = require('debug'); const { setupBrowser } = require('@testing-library/webdriverio');

const debug = debugModule('box:wdio-utils:step_definitions:interact');

When('I {word} the/a(n) {word} named/called/labelled/labeled {string}', (action, ariaRole, text) => { setupBrowser(browser); browser.findByRole(ariaRole, { name: text })[action](); browser.pause(5000); });`

But with this I would have to invoke setupBrowser(browser); within every stepdefenition. I tried invoking it in the before() hook in webdriverio conf. But that gave an error. Which common place can this be invoked?

olivierwilkinson commented 3 years ago

What error are you finding? There shouldn't be any problem with calling setupBrowser in the before block, it's working for me if I try to do it in the repo's tests but we aren't using cucumber or anything. It would probably break if the browser is entirely recreated between tests or something? A sessionReload call would still be fine though!

suchitrak commented 3 years ago

Sorry my bad. It works fine if added to Before hook.

dietergeerts commented 3 years ago

@suchitrak , which version of cucumber and wdio are you using? I'm unsuccessful of getting this to work with latest of @wdio/cucumber-framework.

suchitrak commented 3 years ago

It was v6