Skip to content

Commit

Permalink
docs: add basic typescript usage docs
Browse files Browse the repository at this point in the history
  • Loading branch information
KuznetsovRoman committed Mar 27, 2024
1 parent 540893c commit 3d02d69
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ Hermione is a utility for integration testing of web pages using [WebdriverIO](h
- [AssertView](#assertview)
- [RunStep](#runstep)
- [OpenAndWait](#openandwait)
- [Typescript usage](#typescript-usage)
- [hermione.ctx typings](#hermionectx-typings)
- [.hermione.conf.js](#hermioneconfjs)
- [sets](#sets)
- [browsers](#browsers)
Expand Down Expand Up @@ -826,6 +828,48 @@ Parameters:
- ignoreNetworkErrorsPatterns (optional) `Array<String | RegExp>` - Array of url patterns to ignore network requests errors. Has a priority over `shouldThrowError`
- timeout (optional) `Number` - Page load timeout. [pageLoadTimeout](#pageloadtimeout) by default. Throws an error, if selectors are still not exist after timeout, or predicate is still resolving false.

## Typescript usage

To write hermione tests on typescript, you would need to install `ts-node`:

```bash
npm i -D ts-node
```

And include hermione types in your `tsconfig.json` file:

```js
// tsconfig.json
{
// other tsconfig options
"compilerOptions": {
// other compiler options
"types": [
// other types
"hermione",
]
}
}
```

Now you will be able to write hermione tests using typescript.

### hermione.ctx typings

If you want to extend hermione.ctx typings, you could use module augmentation:

```ts
import type { HermioneCtx } from "hermione";

declare module "hermione" {
interface HermioneCtx {
someFunc(): void;
}
}
```

Now `hermione.ctx` will have `someFunc` typings

## .hermione.conf.js
`hermione` is tuned using a configuration file. By default, it uses `.hermione.conf.js`, but you can use the `--config` option to specify a path to the configuration file.

Expand Down

0 comments on commit 3d02d69

Please sign in to comment.