From daecbb90fe4587569bc3de83a7d6f472f2cd9096 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Tue, 19 Mar 2024 10:49:24 +0100 Subject: [PATCH] test: modify remote specs to allow skip or only (#41620) --- spec/lib/spec-helpers.ts | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/spec/lib/spec-helpers.ts b/spec/lib/spec-helpers.ts index 9bad7f322aea..b12ca77b5574 100644 --- a/spec/lib/spec-helpers.ts +++ b/spec/lib/spec-helpers.ts @@ -176,8 +176,8 @@ export function useRemoteContext (opts?: any) { }); } -export async function itremote (name: string, fn: Function, args?: any[]) { - it(name, async () => { +async function runRemote (type: 'skip' | 'none' | 'only', name: string, fn: Function, args?: any[]) { + const wrapped = async () => { const w = await getRemoteContext(); const { ok, message } = await w.webContents.executeJavaScript(`(async () => { try { @@ -192,9 +192,30 @@ export async function itremote (name: string, fn: Function, args?: any[]) { } })()`); if (!ok) { throw new AssertionError(message); } - }); + }; + + let runFn: any = it; + if (type === 'only') { + runFn = it.only; + } else if (type === 'skip') { + runFn = it.skip; + } + + runFn(name, wrapped); } +export const itremote = Object.assign( + (name: string, fn: Function, args?: any[]) => { + runRemote('none', name, fn, args); + }, { + only: (name: string, fn: Function, args?: any[]) => { + runRemote('only', name, fn, args); + }, + skip: (name: string, fn: Function, args?: any[]) => { + runRemote('skip', name, fn, args); + } + }); + export async function listen (server: http.Server | https.Server | http2.Http2SecureServer) { const hostname = '127.0.0.1'; await new Promise(resolve => server.listen(0, hostname, () => resolve()));