Skip to content

Commit

Permalink
feat: added expect-playwright
Browse files Browse the repository at this point in the history
  • Loading branch information
mxschmitt committed Apr 2, 2020
1 parent b15a870 commit d7c165c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,13 @@ module.exports = {

Other options are documented in [jest-dev-server](https://github.com/smooth-code/jest-puppeteer/tree/master/packages/jest-dev-server).

## expect-playwright

There is a utility package [expect-playwright](https://github.com/mxschmitt/expect-playwright) which simplifies the expect statements in combination with Playwright to make e.g. shorter text comparisons.

## ESLint globals / `'page' is not defined`

There is [eslint-plugin-jest-playwright](https://github.com/mxschmitt/eslint-plugin-jest-playwright) available which includes the globals for using jest-playwright.
There is [eslint-plugin-jest-playwright](https://github.com/mxschmitt/eslint-plugin-jest-playwright) available which includes the globals for using jest-playwright.

## Unstable and experimental API

Expand Down Expand Up @@ -191,37 +195,37 @@ Example Jest configuration in combination with [ts-jest](https://github.com/kuls
module.exports = {
preset: 'jest-playwright-preset',
transform: {
"^.+\\.ts$": "ts-jest"
'^.+\\.ts$': 'ts-jest',
},
};
}
```

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

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

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

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

or via `types`:

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

Expand Down
5 changes: 4 additions & 1 deletion jest-preset.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"globalSetup": "jest-playwright-preset/setup.js",
"globalTeardown": "jest-playwright-preset/teardown.js",
"testEnvironment": "jest-playwright-preset"
"testEnvironment": "jest-playwright-preset",
"setupFilesAfterEnv": [
"expect-playwright"
]
}
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"jest-environment-node": "^25.2.3"
},
"dependencies": {
"expect-playwright": "^0.1.0",
"jest-dev-server": "^4.4.0"
},
"devDependencies": {
Expand Down

0 comments on commit d7c165c

Please sign in to comment.