Skip to content

Commit

Permalink
chore: generate changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianSedzik committed Jan 24, 2024
1 parent 520d23b commit 8451727
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions .changeset/slimy-spiders-cover.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
"playwright-decorators": minor
---

Add support for fixtures

This release introduce a new method `extend<T>(customFixture)` that allows to create decorators (`afterAll`, `afterEach`, `test`, `beforeAll`, `beforeEach`) with access to custom fixtures.

```ts
import { test as base } from 'playwright';
import { suite, test, extend } from 'playwright-decorators';

// #1 Create fixture type
type UserFixture = {
user: {
firstName: string;
lastName: string;
}
}

// #2 Create user fixture
const withUser = base.extend<UserFixture>({
user: async ({}, use) => {
await use({
firstName: 'John',
lastName: 'Doe'
})
}
})

// #3 Generate afterAll, afterEach, test, beforeAll, beforeEach decorators with access to the user fixture
const {
afterAll,
afterEach,
test,
beforeAll,
beforeEach,
} = extend<UserFixture>(withUser);

// #4 Use decorators
@suite()
class MyTestSuite {
@beforeAll()
async beforeAll({ user }: TestArgs<UserFixture>) { // have access to user fixture
// ...
}

@test()
async test({ user }: TestArgs<UserFixture>) { // have access to user fixture
// ...
}
}
```

0 comments on commit 8451727

Please sign in to comment.