mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -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)
|
||
|
}
|