Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add usage with TypeScript #95

Merged
merged 2 commits into from
Apr 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,50 @@ If there is no defined browsers in config it will run tests for chromium browser
"test:parallel": "jest-playwright --parallel"
```

## Usage with Typescript

Example Jest configuration in combination with [ts-jest](https://github.com/kulshekhar/ts-jest):

```javascript
module.exports = {
preset: 'jest-playwright-preset',
transform: {
"^.+\\.ts$": "ts-jest"
},
};
```

Types are also available, which you can either use via directly in your test:

```typescript
/// <reference types="jest-playwright-preset" />
```

or at your central `tsconfig.json` either via `files`:

```
{
"files": [
"./global.d.ts",
"node_modules/jest-playwright-preset/types/global.d.ts"
],
}
```

or via `types`:

```
{
"compilerOptions": {
"types": [
"jest-playwright-preset"
]
},
}
```

It's important to not change the `testEnvironment` to `node`. Otherwise it won't work.

## Known issues

### Error reporting with Jest
Expand Down