1- import { expect , test } from 'vitest'
1+ import { test as baseTest , expect } from 'vitest'
22import { page , server } from 'vitest/browser'
33
44const httpMethods = [
@@ -9,6 +9,9 @@ const httpMethods = [
99 { method : 'DELETE' as const , url : '/api/route-delete' , status : 200 , body : { ok : true } } ,
1010] as const
1111
12+ const skipWebdriver = server . provider === 'webdriverio'
13+ const test = baseTest . runIf ( ! skipWebdriver )
14+
1215test . each ( httpMethods ) ( 'fulfills mocked %s request' , async ( entry ) => {
1316 const { method, url, body, status } = entry
1417 const methodName = method . toLowerCase ( ) as Lowercase < typeof method >
@@ -59,8 +62,7 @@ test('fulfills mocked OPTIONS request', async () => {
5962 expect ( response . headers . get ( 'Allow' ) ) . toBe ( 'GET, POST, OPTIONS' )
6063} )
6164
62- // For some reason, this test only works in Playwright
63- test . runIf ( server . provider === 'playwright' ) ( 'fulfills mocked request with wildcard path' , async ( ) => {
65+ test ( 'fulfills mocked request with wildcard path' , async ( ) => {
6466 await page . http . get ( '/api/products/*' , ( ) => {
6567 return new Response ( JSON . stringify ( { wildcard : true } ) , {
6668 status : 200 ,
@@ -73,8 +75,7 @@ test.runIf(server.provider === 'playwright')('fulfills mocked request with wildc
7375 expect ( await simple . json ( ) ) . toEqual ( { wildcard : true } )
7476} )
7577
76- // For WebdriverIO, it uses URLPattern internally, and matching with RegExp does not work correctly, so this test is only run in Playwright
77- test . runIf ( server . provider === 'playwright' ) ( 'fulfills mocked request with RegExp path' , async ( ) => {
78+ test ( 'fulfills mocked request with RegExp path' , async ( ) => {
7879 await page . http . get ( / \/ a p i \/ f i l e s \/ ( \d + ) $ / , ( ) => {
7980 return new Response ( JSON . stringify ( { matched : true } ) , {
8081 status : 200 ,
0 commit comments