test: modify remote specs to allow skip or only (#41620)
This commit is contained in:
parent
193e162ec6
commit
daecbb90fe
1 changed files with 24 additions and 3 deletions
|
@ -176,8 +176,8 @@ export function useRemoteContext (opts?: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function itremote (name: string, fn: Function, args?: any[]) {
|
async function runRemote (type: 'skip' | 'none' | 'only', name: string, fn: Function, args?: any[]) {
|
||||||
it(name, async () => {
|
const wrapped = async () => {
|
||||||
const w = await getRemoteContext();
|
const w = await getRemoteContext();
|
||||||
const { ok, message } = await w.webContents.executeJavaScript(`(async () => {
|
const { ok, message } = await w.webContents.executeJavaScript(`(async () => {
|
||||||
try {
|
try {
|
||||||
|
@ -192,9 +192,30 @@ export async function itremote (name: string, fn: Function, args?: any[]) {
|
||||||
}
|
}
|
||||||
})()`);
|
})()`);
|
||||||
if (!ok) { throw new AssertionError(message); }
|
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) {
|
export async function listen (server: http.Server | https.Server | http2.Http2SecureServer) {
|
||||||
const hostname = '127.0.0.1';
|
const hostname = '127.0.0.1';
|
||||||
await new Promise<void>(resolve => server.listen(0, hostname, () => resolve()));
|
await new Promise<void>(resolve => server.listen(0, hostname, () => resolve()));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue