forked from vitest-dev/vitest
-
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(browser): support "none" provider and update lit example to use …
…it (vitest-dev#4427)
- Loading branch information
1 parent
488b526
commit 8abcc58
Showing
13 changed files
with
265 additions
and
78 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "node16", | ||
"target": "es2020", | ||
"moduleResolution": "Node16", | ||
"experimentalDecorators": true, | ||
"useDefineForClassFields": false, | ||
"importsNotUsedAsValues": "preserve" | ||
"verbatimModuleSyntax": 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
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,5 +1,7 @@ | ||
import { PlaywrightBrowserProvider } from './playwright' | ||
import { WebdriverBrowserProvider } from './webdriver' | ||
import { NoneBrowserProvider } from './none' | ||
|
||
export const webdriverio = WebdriverBrowserProvider | ||
export const playwright = PlaywrightBrowserProvider | ||
export const none = NoneBrowserProvider |
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,40 @@ | ||
import type { Awaitable } from 'vitest' | ||
import type { BrowserProvider, WorkspaceProject } from 'vitest/node' | ||
|
||
export class NoneBrowserProvider implements BrowserProvider { | ||
public name = 'none' | ||
private ctx!: WorkspaceProject | ||
private open = false | ||
|
||
getSupportedBrowsers() { | ||
// `none` is not restricted to certain browsers. | ||
return [] | ||
} | ||
|
||
isOpen() { | ||
return this.open | ||
} | ||
|
||
async initialize(ctx: WorkspaceProject) { | ||
this.ctx = ctx | ||
this.open = false | ||
} | ||
|
||
catchError(_cb: (error: Error) => Awaitable<void>) { | ||
return () => {} | ||
} | ||
|
||
async openPage(_url: string) { | ||
this.open = true | ||
if (!this.ctx.browser) | ||
throw new Error('Browser is not initialized') | ||
const options = this.ctx.browser.config.server | ||
const _open = options.open | ||
options.open = _url | ||
this.ctx.browser.openBrowser() | ||
options.open = _open | ||
} | ||
|
||
async close() { | ||
} | ||
} |
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,3 +1,3 @@ | ||
export const isNode: boolean = typeof process < 'u' && typeof process.stdout < 'u' && !process.versions?.deno && !globalThis.window | ||
export const isBrowser: boolean = typeof window !== 'undefined' | ||
export { isCI } from 'std-env' | ||
export { isCI, provider as stdProvider } from 'std-env' |
Oops, something went wrong.