You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you want to get types for your [custom helper](https://codecept.io/helpers/#configuration), you can add their automatically with CodeceptJS command `npx codeceptjs def`.
109
+
If you want to get types for your [custom helper](https://codecept.io/helpers/#configuration), you can add their automatically with CodeceptJS command `npx codeceptjs def`.
110
110
111
111
For example, if you add the new step `printMessage` for your custom helper like this:
112
112
```js
@@ -121,9 +121,9 @@ export = CustomHelper
121
121
```
122
122
123
123
Then you need to add this helper to your `codecept.conf.js` like in this [docs](https://codecept.io/helpers/#configuration).
124
-
And then run the command `npx codeceptjs def`.
124
+
And then run the command `npx codeceptjs def`.
125
125
126
-
As result our `steps.d.ts` file will be updated like this:
126
+
As result our `steps.d.ts` file will be updated like this:
You can define [custom strict locators](https://codecept.io/locators/#custom-strict-locators) that can be used in all methods taking a locator (parameter type `LocatorOrString`).
163
+
164
+
Example: A custom strict locator with a `data` property, which can be used like this:
165
+
166
+
```ts
167
+
I.click({ data: 'user-login' });
168
+
```
169
+
170
+
In order to use the custom locator in TypeScript code, its type shape needs to be registered in the interface `CustomLocators` in your `steps.d.ts` file:
171
+
172
+
```ts
173
+
/// <referencetypes='codeceptjs' />
174
+
...
175
+
176
+
declarenamespaceCodeceptJS {
177
+
...
178
+
179
+
interfaceCustomLocators {
180
+
data: { data:string };
181
+
}
182
+
}
183
+
```
184
+
185
+
The property keys used in the `CustomLocators` interface do not matter (only the *types* of the interface properties are used). For simplicity it is recommended to use the name that is also used in your custom locator itself.
186
+
187
+
You can also define more complicated custom locators with multiple (also optional) properties:
0 commit comments