mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-04 01:26:36 -05:00
18 lines
465 B
TypeScript
18 lines
465 B
TypeScript
|
import { RouteHandler, RouteMatcher } from 'cypress/types/net-stubbing'
|
||
|
|
||
|
export const interceptAsync = (route: RouteMatcher, alias: string) => {
|
||
|
const deferred: { resolve: (value: RouteHandler) => void } = {
|
||
|
resolve: () => {},
|
||
|
}
|
||
|
|
||
|
const promise = new Promise<RouteHandler>(resolve => {
|
||
|
deferred.resolve = resolve
|
||
|
})
|
||
|
|
||
|
cy.intercept(route, req => {
|
||
|
return promise.then(response => req.reply(response))
|
||
|
}).as(alias)
|
||
|
|
||
|
return cy.wrap(deferred)
|
||
|
}
|