@vitest/browser
Advanced tools
Comparing version 2.1.0-beta.6 to 2.1.0-beta.7
@@ -164,2 +164,8 @@ import type { SerializedConfig } from 'vitest' | ||
/** | ||
* Change a file input element to have the specified files. Uses provider's API under the hood. | ||
* @see {@link https://playwright.dev/docs/api/class-locator#locator-set-input-files} Playwright API | ||
* @see {@link https://testing-library.com/docs/user-event/utility#upload} testing-library API | ||
*/ | ||
upload: (element: Element | Locator, files: File | File[] | string | string[]) => Promise<void> | ||
/** | ||
* Fills an input element with text. This will remove any existing text in the input before typing the new text. | ||
@@ -341,2 +347,7 @@ * Uses provider's API under the hood. | ||
): Promise<void> | ||
/** | ||
* Change a file input element to have the specified files. Uses provider's API under the hood. | ||
* @see {@link https://vitest.dev/guide/browser/interactivity-api#userevent-upload} | ||
*/ | ||
upload: (files: File | File[] | string | string[]) => Promise<void> | ||
@@ -343,0 +354,0 @@ /** |
{ | ||
"_preload-helper-YsBSwBkS.js": { | ||
"file": "__vitest_browser__/preload-helper-YsBSwBkS.js", | ||
"_preload-helper-D-WYp1PK.js": { | ||
"file": "__vitest_browser__/preload-helper-D-WYp1PK.js", | ||
"name": "preload-helper" | ||
}, | ||
"orchestrator.html": { | ||
"file": "__vitest_browser__/orchestrator-CoMoQEYq.js", | ||
"file": "__vitest_browser__/orchestrator-qtq9EW1J.js", | ||
"name": "orchestrator", | ||
@@ -12,7 +12,7 @@ "src": "orchestrator.html", | ||
"imports": [ | ||
"_preload-helper-YsBSwBkS.js" | ||
"_preload-helper-D-WYp1PK.js" | ||
] | ||
}, | ||
"tester/tester.html": { | ||
"file": "__vitest_browser__/tester-C7y_vb57.js", | ||
"file": "__vitest_browser__/tester-Bm6k0JOu.js", | ||
"name": "tester", | ||
@@ -22,5 +22,5 @@ "src": "tester/tester.html", | ||
"imports": [ | ||
"_preload-helper-YsBSwBkS.js" | ||
"_preload-helper-D-WYp1PK.js" | ||
] | ||
} | ||
} |
@@ -20,2 +20,3 @@ const moduleCache = new Map(); | ||
wrapModule, | ||
wrapDynamicImport: wrapModule, | ||
moduleCache, | ||
@@ -22,0 +23,0 @@ config: { __VITEST_CONFIG__ }, |
@@ -143,2 +143,5 @@ // @__NO_SIDE_EFFECTS__ | ||
}, | ||
upload(element, files) { | ||
return convertToLocator(element).upload(files); | ||
}, | ||
// non userEvent events, but still useful | ||
@@ -145,0 +148,0 @@ fill(element, text, options) { |
import { CDPSession, BrowserServerState as BrowserServerState$1, BrowserServerStateContext, BrowserServer as BrowserServer$1, WorkspaceProject, Vite, BrowserProvider, BrowserScript, Vitest, ProcessPool } from 'vitest/node'; | ||
import { Plugin } from 'vitest/config'; | ||
import * as vitest from 'vitest'; | ||
import { File, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig } from 'vitest'; | ||
import { RunnerTestFile, TaskResultPack, AfterSuiteRunMeta, CancelReason, UserConsoleLog, SnapshotResult, SerializedConfig } from 'vitest'; | ||
import { ErrorWithDiff } from '@vitest/utils'; | ||
import { StackTraceParserOptions } from '@vitest/utils/source-map'; | ||
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node'; | ||
@@ -27,3 +28,3 @@ type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never; | ||
onUnhandledError: (error: unknown, type: string) => Promise<void>; | ||
onCollected: (files?: File[]) => Promise<void>; | ||
onCollected: (files?: RunnerTestFile[]) => Promise<void>; | ||
onTaskUpdate: (packs: TaskResultPack[]) => void; | ||
@@ -40,14 +41,7 @@ onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void; | ||
debug: (...args: string[]) => void; | ||
resolveId: (id: string, importer?: string) => Promise<{ | ||
id: string; | ||
url: string; | ||
optimized: boolean; | ||
} | null>; | ||
resolveId: (id: string, importer?: string) => Promise<ServerIdResolution | null>; | ||
triggerCommand: <T>(contextId: string, command: string, testPath: string | undefined, payload: unknown[]) => Promise<T>; | ||
resolveMock: (id: string, importer: string, hasFactory: boolean) => Promise<{ | ||
type: 'factory' | 'redirect' | 'automock'; | ||
mockPath?: string | null; | ||
resolvedId: string; | ||
needsInterop?: boolean; | ||
}>; | ||
resolveMock: (id: string, importer: string, options: { | ||
mock: 'spy' | 'factory' | 'auto'; | ||
}) => Promise<ServerMockResolution>; | ||
invalidate: (ids: string[]) => void; | ||
@@ -54,0 +48,0 @@ getBrowserFileSourceMap: (id: string) => SourceMap | null | { |
@@ -233,2 +233,3 @@ import { UserEventClickOptions, UserEventHoverOptions, UserEventFillOptions, UserEventDragAndDropOptions, LocatorScreenshotOptions, LocatorByRoleOptions, LocatorOptions } from '@vitest/browser/context'; | ||
fill(text: string, options?: UserEventFillOptions): Promise<void>; | ||
upload(files: string | string[] | File | File[]): Promise<void>; | ||
dropTo(target: Locator, options?: UserEventDragAndDropOptions): Promise<void>; | ||
@@ -235,0 +236,0 @@ selectOptions(value: HTMLElement | HTMLElement[] | Locator | Locator[] | string | string[]): Promise<void>; |
import '@vitest/browser/context'; | ||
import '../public-utils-D6S2-5kI.js'; | ||
export { L as Locator, s as selectorEngine } from '../index-DcU_z8HM.js'; | ||
export { L as Locator, s as selectorEngine } from '../index-Cgg35wOd.js'; | ||
import 'vitest/utils'; |
import { page, server } from '@vitest/browser/context'; | ||
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector } from '../public-utils-D6S2-5kI.js'; | ||
import { s as selectorEngine, L as Locator } from '../index-DcU_z8HM.js'; | ||
import { s as selectorEngine, L as Locator } from '../index-Cgg35wOd.js'; | ||
import 'vitest/utils'; | ||
@@ -5,0 +5,0 @@ |
import { page, server } from '@vitest/browser/context'; | ||
import { userEvent } from '@testing-library/user-event'; | ||
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-D6S2-5kI.js'; | ||
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-DcU_z8HM.js'; | ||
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-Cgg35wOd.js'; | ||
import 'vitest/utils'; | ||
@@ -67,2 +67,5 @@ | ||
} | ||
async upload(file) { | ||
return userEvent.upload(this.element(), file); | ||
} | ||
selectOptions(options_) { | ||
@@ -69,0 +72,0 @@ const options = (Array.isArray(options_) ? options_ : [options_]).map((option) => { |
import { page, server } from '@vitest/browser/context'; | ||
import { g as getByLabelSelector, a as getByRoleSelector, b as getByTestIdSelector, c as getByAltTextSelector, d as getByPlaceholderSelector, e as getByTextSelector, f as getByTitleSelector, h as getElementError } from '../public-utils-D6S2-5kI.js'; | ||
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-DcU_z8HM.js'; | ||
import { s as selectorEngine, L as Locator, c as convertElementToCssSelector } from '../index-Cgg35wOd.js'; | ||
import 'vitest/utils'; | ||
@@ -5,0 +5,0 @@ |
@@ -1,2 +0,2 @@ | ||
import { W as WebdriverBrowserProvider, P as PlaywrightBrowserProvider } from './webdriver-BdVqnfdE.js'; | ||
import { W as WebdriverBrowserProvider, P as PlaywrightBrowserProvider } from './webdriver-Cv9wga63.js'; | ||
@@ -3,0 +3,0 @@ class PreviewBrowserProvider { |
@@ -1,1 +0,1 @@ | ||
const{parse:$parse,stringify:$stringify}=JSON;const{keys}=Object;const Primitive=String;const primitive="string";const ignore={};const object="object";const noop=(_,value)=>value;const primitives=value=>value instanceof Primitive?Primitive(value):value;const Primitives=(_,value)=>typeof value===primitive?new Primitive(value):value;const revive=(input,parsed,output,$)=>{const lazy=[];for(let ke=keys(output),{length}=ke,y=0;y<length;y++){const k=ke[y];const value=output[k];if(value instanceof Primitive){const tmp=input[value];if(typeof tmp===object&&!parsed.has(tmp)){parsed.add(tmp);output[k]=ignore;lazy.push({k,a:[input,parsed,tmp,$]})}else output[k]=$.call(output,k,tmp)}else if(output[k]!==ignore)output[k]=$.call(output,k,value)}for(let{length}=lazy,i=0;i<length;i++){const{k,a}=lazy[i];output[k]=$.call(output,k,revive.apply(null,a))}return output};const parse=(text,reviver)=>{const input=$parse(text,Primitives).map(primitives);const value=input[0];const $=noop;const tmp=typeof value===object&&value?revive(input,new Set,value,$):value;return $.call({"":tmp},"",tmp)};function getBrowserState(){return window.__vitest_browser_runner__}const config=getBrowserState().config;const contextId=getBrowserState().contextId;const providedContext=parse(getBrowserState().providedContext);const state={ctx:{pool:"browser",worker:"./browser.js",workerId:1,config,projectName:config.name||"",files:[],environment:{name:"browser",options:null},providedContext,invalidates:[]},onCancel:null,mockMap:new Map,config,environment:{name:"browser",transformMode:"web",setup(){throw new Error("Not called in the browser")}},moduleCache:getBrowserState().moduleCache,rpc:null,durations:{environment:0,prepare:performance.now()},providedContext};globalThis.__vitest_browser__=true;globalThis.__vitest_worker__=state;getBrowserState().cdp=createCdp();function rpc(){return state.rpc}function createCdp(){const listenersMap=new WeakMap;function getId(listener){const id=listenersMap.get(listener)||crypto.randomUUID();listenersMap.set(listener,id);return id}const listeners={};const error=err=>{window.dispatchEvent(new ErrorEvent("error",{error:err}))};const cdp={send(method,params){return rpc().sendCdpEvent(contextId,method,params)},on(event,listener){const listenerId=getId(listener);listeners[event]=listeners[event]||[];listeners[event].push(listener);rpc().trackCdpEvent(contextId,"on",event,listenerId).catch(error);return cdp},once(event,listener){const listenerId=getId(listener);const handler=data=>{listener(data);cdp.off(event,listener)};listeners[event]=listeners[event]||[];listeners[event].push(handler);rpc().trackCdpEvent(contextId,"once",event,listenerId).catch(error);return cdp},off(event,listener){const listenerId=getId(listener);if(listeners[event]){listeners[event]=listeners[event].filter(l=>l!==listener)}rpc().trackCdpEvent(contextId,"off",event,listenerId).catch(error);return cdp},emit(event,payload){if(listeners[event]){listeners[event].forEach(l=>{try{l(payload)}catch(err){error(err)}})}}};return cdp} | ||
const{parse:$parse,stringify:$stringify}=JSON;const{keys}=Object;const Primitive=String;const primitive="string";const ignore={};const object="object";const noop=(_,value)=>value;const primitives=value=>value instanceof Primitive?Primitive(value):value;const Primitives=(_,value)=>typeof value===primitive?new Primitive(value):value;const revive=(input,parsed,output,$)=>{const lazy=[];for(let ke=keys(output),{length}=ke,y=0;y<length;y++){const k=ke[y];const value=output[k];if(value instanceof Primitive){const tmp=input[value];if(typeof tmp===object&&!parsed.has(tmp)){parsed.add(tmp);output[k]=ignore;lazy.push({k,a:[input,parsed,tmp,$]})}else output[k]=$.call(output,k,tmp)}else if(output[k]!==ignore)output[k]=$.call(output,k,value)}for(let{length}=lazy,i=0;i<length;i++){const{k,a}=lazy[i];output[k]=$.call(output,k,revive.apply(null,a))}return output};const parse=(text,reviver)=>{const input=$parse(text,Primitives).map(primitives);const value=input[0];const $=noop;const tmp=typeof value===object&&value?revive(input,new Set,value,$):value;return $.call({"":tmp},"",tmp)};function getBrowserState(){return window.__vitest_browser_runner__}const config=getBrowserState().config;const contextId=getBrowserState().contextId;const providedContext=parse(getBrowserState().providedContext);const state={ctx:{pool:"browser",worker:"./browser.js",workerId:1,config,projectName:config.name||"",files:[],environment:{name:"browser",options:null},providedContext,invalidates:[]},onCancel:null,config,environment:{name:"browser",transformMode:"web",setup(){throw new Error("Not called in the browser")}},moduleCache:getBrowserState().moduleCache,rpc:null,durations:{environment:0,prepare:performance.now()},providedContext};globalThis.__vitest_browser__=true;globalThis.__vitest_worker__=state;getBrowserState().cdp=createCdp();function rpc(){return state.rpc}function createCdp(){const listenersMap=new WeakMap;function getId(listener){const id=listenersMap.get(listener)||crypto.randomUUID();listenersMap.set(listener,id);return id}const listeners={};const cdp={send(method,params){return rpc().sendCdpEvent(contextId,method,params)},on(event,listener){const listenerId=getId(listener);listeners[event]=listeners[event]||[];listeners[event].push(listener);rpc().trackCdpEvent(contextId,"on",event,listenerId).catch(error);return cdp},once(event,listener){const listenerId=getId(listener);const handler=data=>{listener(data);cdp.off(event,listener)};listeners[event]=listeners[event]||[];listeners[event].push(handler);rpc().trackCdpEvent(contextId,"once",event,listenerId).catch(error);return cdp},off(event,listener){const listenerId=getId(listener);if(listeners[event]){listeners[event]=listeners[event].filter(l=>l!==listener)}rpc().trackCdpEvent(contextId,"off",event,listenerId).catch(error);return cdp},emit(event,payload){if(listeners[event]){listeners[event].forEach(l=>{try{l(payload)}catch(err){error(err)}})}}};return cdp}function error(err){window.dispatchEvent(new ErrorEvent("error",{error:err}))} |
{ | ||
"name": "@vitest/browser", | ||
"type": "module", | ||
"version": "2.1.0-beta.6", | ||
"version": "2.1.0-beta.7", | ||
"description": "Browser running for Vitest", | ||
@@ -65,3 +65,3 @@ "license": "MIT", | ||
"webdriverio": "*", | ||
"vitest": "2.1.0-beta.6" | ||
"vitest": "2.1.0-beta.7" | ||
}, | ||
@@ -85,4 +85,5 @@ "peerDependenciesMeta": { | ||
"sirv": "^2.0.4", | ||
"tinyrainbow": "^1.2.0", | ||
"ws": "^8.18.0", | ||
"@vitest/utils": "2.1.0-beta.6" | ||
"@vitest/utils": "2.1.0-beta.7" | ||
}, | ||
@@ -96,2 +97,3 @@ "devDependencies": { | ||
"ivya": "^1.1.1", | ||
"mime": "^4.0.4", | ||
"pathe": "^1.1.2", | ||
@@ -103,6 +105,7 @@ "periscopic": "^4.0.2", | ||
"webdriverio": "^8.40.2", | ||
"@vitest/runner": "2.1.0-beta.6", | ||
"@vitest/ui": "2.1.0-beta.6", | ||
"@vitest/ws-client": "2.1.0-beta.6", | ||
"vitest": "2.1.0-beta.6" | ||
"@vitest/mocker": "2.1.0-beta.7", | ||
"@vitest/ui": "2.1.0-beta.7", | ||
"@vitest/runner": "2.1.0-beta.7", | ||
"vitest": "2.1.0-beta.7", | ||
"@vitest/ws-client": "2.1.0-beta.7" | ||
}, | ||
@@ -109,0 +112,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
1687029
27232
11
18
+ Addedtinyrainbow@^1.2.0
+ Added@vitest/expect@2.1.0-beta.7(transitive)
+ Added@vitest/mocker@2.1.0-beta.7(transitive)
+ Added@vitest/pretty-format@2.1.0-beta.7(transitive)
+ Added@vitest/runner@2.1.0-beta.7(transitive)
+ Added@vitest/snapshot@2.1.0-beta.7(transitive)
+ Added@vitest/spy@2.1.0-beta.7(transitive)
+ Added@vitest/utils@2.1.0-beta.7(transitive)
+ Addedtinyexec@0.3.1(transitive)
+ Addedvite-node@2.1.0-beta.7(transitive)
+ Addedvitest@2.1.0-beta.7(transitive)
- Removed@ampproject/remapping@2.3.0(transitive)
- Removed@jridgewell/gen-mapping@0.3.5(transitive)
- Removed@jridgewell/resolve-uri@3.1.2(transitive)
- Removed@jridgewell/set-array@1.2.1(transitive)
- Removed@jridgewell/trace-mapping@0.3.25(transitive)
- Removed@vitest/expect@2.1.0-beta.6(transitive)
- Removed@vitest/pretty-format@2.1.0-beta.6(transitive)
- Removed@vitest/runner@2.1.0-beta.6(transitive)
- Removed@vitest/snapshot@2.1.0-beta.6(transitive)
- Removed@vitest/spy@2.1.0-beta.6(transitive)
- Removed@vitest/utils@2.1.0-beta.6(transitive)
- Removedexeca@8.0.1(transitive)
- Removedget-stream@8.0.1(transitive)
- Removedhuman-signals@5.0.0(transitive)
- Removedis-stream@3.0.0(transitive)
- Removedmerge-stream@2.0.0(transitive)
- Removedmimic-fn@4.0.0(transitive)
- Removednpm-run-path@5.3.0(transitive)
- Removedonetime@6.0.0(transitive)
- Removedpath-key@4.0.0(transitive)
- Removedstrip-final-newline@3.0.0(transitive)
- Removedvite-node@2.1.0-beta.6(transitive)
- Removedvitest@2.1.0-beta.6(transitive)
Updated@vitest/utils@2.1.0-beta.7