Closed jeffb-sfdc closed 1 year ago
how does one use strict mode and import browser and $ (in v4.x)?
Not sure, we documented adding @wdio/globals/types
to your tsconfig.json
"types"
list. That usually should do the trick.
I didn't see this documented (in README.md or in https://webdriverio-community.github.io/wdio-vscode-service/) but maybe I missed it, or maybe it is elsewhere. Could you point me to where importing browser and adding globals/types is documented?
I ask because I'm following the blueprint that's in the current (v5) codebase, but it doesn't work (or what I'm doing isn't working) using v4.2.1. I can go into more detail as to what I'm seeing, but first would like to see if this is documented first, as perhaps I'm doing something wrong.
Could you point me to where importing browser and adding globals/types is documented?
It is documented in the official WebdriverIO docs: https://webdriver.io/docs/api/globals. Note this only applies for WebdriverIO v8. If you are using and older version, I recommend to update.
FWIW, we're using wdio-vscode-service 4.2.1, and after adding @wdio/globals v8.0.5, we now have type definitions for browser.
We are using wdio-service-vscode 4.1.0 (we should probably update to 4.2.1 but we can't update to v5). In our code we have many places where we use
browser
,$
, and$$
.The code runs fine but we've turned on strict mode and are getting errors about browser and the others not being defined.
Looking through the examples for wdio-service-vscode I see
in v5.0.0 (https://github.com/webdriverio-community/wdio-vscode-service/blob/5.0.0/test/specs/basic.e2e.ts)
...but not in v4.2.1 (https://github.com/webdriverio-community/wdio-vscode-service/blob/4.2.1/test/specs/basic.e2e.ts)
Due to the change in how modules are exported we aren't able to update to v5.
In v4.2.1 (or v4.1.0), is it possible to import these globals, so strict mode doesn't complain about them? Yes, we can add a TS comment to silence the warning, but this would need to be done in many places and I don't want to do that.
I've tried many things (like adding @wdio/globals to list of dependencies in our project's package.json) but nothing has worked out, so I'm wondering, how does one use strict mode and import browser and $ (in v4.x)?