-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(browser): run tests in parallel in headless mode, add `page.scre…
…enshot` method (#5853)
- Loading branch information
1 parent
0a71594
commit 81c42fc
Showing
49 changed files
with
1,402 additions
and
364 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
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 |
---|---|---|
@@ -1,8 +1,20 @@ | ||
import type { Browser, LaunchOptions } from 'playwright' | ||
import type { | ||
BrowserContextOptions, | ||
FrameLocator, | ||
LaunchOptions, | ||
Locator, | ||
Page, | ||
} from 'playwright' | ||
|
||
declare module 'vitest/node' { | ||
interface BrowserProviderOptions { | ||
launch?: LaunchOptions | ||
page?: Parameters<Browser['newPage']>[0] | ||
context?: Omit<BrowserContextOptions, 'ignoreHTTPSErrors' | 'serviceWorkers'> | ||
} | ||
|
||
export interface BrowserCommandContext { | ||
page: Page | ||
tester: FrameLocator | ||
body: Locator | ||
} | ||
} |
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,90 @@ | ||
import { getBrowserState } from './utils' | ||
|
||
export interface IframeDoneEvent { | ||
type: 'done' | ||
filenames: string[] | ||
id: string | ||
} | ||
|
||
export interface IframeErrorEvent { | ||
type: 'error' | ||
error: any | ||
errorType: string | ||
files: string[] | ||
id: string | ||
} | ||
|
||
export interface IframeViewportEvent { | ||
type: 'viewport' | ||
width: number | ||
height: number | ||
id: string | ||
} | ||
|
||
export interface IframeMockEvent { | ||
type: 'mock' | ||
paths: string[] | ||
mock: string | undefined | null | ||
} | ||
|
||
export interface IframeUnmockEvent { | ||
type: 'unmock' | ||
paths: string[] | ||
} | ||
|
||
export interface IframeMockingDoneEvent { | ||
type: 'mock:done' | 'unmock:done' | ||
} | ||
|
||
export interface IframeMockFactoryRequestEvent { | ||
type: 'mock-factory:request' | ||
id: string | ||
} | ||
|
||
export interface IframeMockFactoryResponseEvent { | ||
type: 'mock-factory:response' | ||
exports: string[] | ||
} | ||
|
||
export interface IframeMockFactoryErrorEvent { | ||
type: 'mock-factory:error' | ||
error: any | ||
} | ||
|
||
export interface IframeViewportChannelEvent { | ||
type: 'viewport:done' | 'viewport:fail' | ||
} | ||
|
||
export interface IframeMockInvalidateEvent { | ||
type: 'mock:invalidate' | ||
} | ||
|
||
export type IframeChannelIncomingEvent = | ||
| IframeViewportEvent | ||
| IframeErrorEvent | ||
| IframeDoneEvent | ||
| IframeMockEvent | ||
| IframeUnmockEvent | ||
| IframeMockFactoryResponseEvent | ||
| IframeMockFactoryErrorEvent | ||
| IframeMockInvalidateEvent | ||
|
||
export type IframeChannelOutgoingEvent = | ||
| IframeMockFactoryRequestEvent | ||
| IframeViewportChannelEvent | ||
| IframeMockingDoneEvent | ||
|
||
export type IframeChannelEvent = | ||
| IframeChannelIncomingEvent | ||
| IframeChannelOutgoingEvent | ||
|
||
export const channel = new BroadcastChannel(`vitest:${getBrowserState().contextId}`) | ||
|
||
export function waitForChannel(event: IframeChannelOutgoingEvent['type']) { | ||
return new Promise<void>((resolve) => { | ||
channel.addEventListener('message', (e) => { | ||
if (e.data?.type === event) | ||
resolve() | ||
}, { once: true }) | ||
}) | ||
} |
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
Oops, something went wrong.