mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-03 09:03:49 -05:00
390d7ed005
Improve synctex Cypress tests GitOrigin-RevId: 282d26d344d8ae08f52b18ef4c12a4c311a6b7ff
17 lines
465 B
TypeScript
17 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)
|
|
}
|