-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add `@preview` decorator * chore: generate changeset * chore: revert changes in examples configuration
- Loading branch information
1 parent
a50e25b
commit a2e7892
Showing
6 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
--- | ||
'playwright-decorators': minor | ||
--- | ||
|
||
Add `@preview` decorator | ||
|
||
Runs a `@test`(s) or `@suite`(s) in preview (headed browser) mode, simulating user interaction (slowing down each operation by 1000ms). | ||
Tests or suites without the `@preview` decorator will not be excluded. | ||
|
||
```ts | ||
import { suite, test, preview, TestArgs } from 'playwright-decorators'; | ||
|
||
// Preview selected test suite(s) | ||
@preview() // <-- Decorate suite with @preview() | ||
@suite() | ||
class PreviewTestSuite { | ||
} | ||
|
||
// Or preview selected test(s) | ||
@suite() | ||
class TestSuite { | ||
@preview() // <-- Decorate test with @preview() | ||
@test() | ||
async test({ page }: TestArgs) { | ||
// ... | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { createSuiteAndTestDecorator } from './custom' | ||
import playwright from '@playwright/test' | ||
|
||
const playwrightPreviewPreset = () => { | ||
// disable timeout, as all operations are slowed down by 1000ms | ||
playwright.describe.configure({ timeout: 0 }) | ||
|
||
playwright.use({ | ||
// enable headed mode | ||
headless: false, | ||
launchOptions: { | ||
// slow down every operation by 1000ms | ||
slowMo: 1000 | ||
} | ||
}) | ||
} | ||
|
||
/** | ||
* Runs a @test(s) or @suite(s) in preview (headed browser) mode, simulating user interaction (slowing down each operation by 1000ms). | ||
* Tests or suites without the @preview decorator will not be excluded. | ||
*/ | ||
export const preview = () => | ||
createSuiteAndTestDecorator( | ||
'preview', | ||
({ suite }) => { | ||
playwrightPreviewPreset() | ||
suite.only = true | ||
}, | ||
({ test }) => { | ||
playwrightPreviewPreset() | ||
test.only = true | ||
} | ||
) |