webdriverio-community / wdio-gmail-service

A WebdriverIO plugin to fetch e-mails from Google Mail.
https://webdriver.io/docs/wdio-gmail-service
MIT License
5 stars 4 forks source link

instance.onPrepare is not a function for CommonJS #133

Closed mateuszseczkowski closed 1 year ago

mateuszseczkowski commented 1 year ago

If the CommonJS module system is used in the project there is a problem with the service hook and thus adding the command to the global browser.

ERROR @wdio/utils:shim: TypeError: instance.onPrepare is not a function at CJSGmailService.before (C:\Repos\automated-tests-wdio\node_modules\wdio-gmail-service\build\cjs\index.js:9:25) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async Promise.all (index 3) at async executeHooksWithArgsShim (C:\Repos\automated-tests-wdio\node_modules\@wdio\utils\build\shim.js:107:20) at async Runner.run (C:\Repos\automated-tests-wdio\node_modules\@wdio\runner\build\index.js:99:9)

It looks like the bug was introduced in the commit just before the release. https://github.com/webdriverio-community/wdio-gmail-service/commit/ef8436a84c8fea1a4691b97114bcd961357ea3ba

I believe before must be used instead of onPrepare.

Temporarily I am using a forked version with a fix https://github.com/mateuszseczkowski/wdio-gmail-service-cjs-fix/commit/ac0b9734d36cd023e25bf3aaeb94e8758c46eb52. If you are fine with that I can prepare a PR heading here.

christian-bromann commented 1 year ago

Hey, thanks for reporting the issue. I pushed a fix which should resolve the problem.