mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
e0d327a3e8
GitOrigin-RevId: a98b145e86f325d1df79bdbcd1825ee5a3ca6def
19 lines
521 B
TypeScript
19 lines
521 B
TypeScript
import { RouteHandler, RouteMatcher } from 'cypress/types/net-stubbing'
|
|
|
|
export const interceptAsync = (route: RouteMatcher, alias: string) => {
|
|
const deferred: { resolve: (value: RouteHandler) => void } = {
|
|
resolve: () => {
|
|
console.error('This should never be called')
|
|
},
|
|
}
|
|
|
|
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)
|
|
}
|