overleaf/services/web/cypress/support/shared/commands/index.ts
Alf Eaton 488c6ff919 Improve compile request mocking in Cypress tests (#12095)
GitOrigin-RevId: fdbc53148e5437e451dab4889232923c823d649e
2023-03-07 09:05:25 +00:00

33 lines
1.2 KiB
TypeScript

import '@testing-library/cypress/add-commands'
import {
interceptCompile,
waitForCompile,
interceptDeferredCompile,
} from './compile'
import { interceptEvents } from './events'
import { interceptSpelling } from './spelling'
// eslint-disable-next-line no-unused-vars,@typescript-eslint/no-namespace
declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace,no-unused-vars
namespace Cypress {
// eslint-disable-next-line no-unused-vars
interface Chainable {
interceptCompile: typeof interceptCompile
interceptEvents: typeof interceptEvents
interceptSpelling: typeof interceptSpelling
waitForCompile: typeof waitForCompile
interceptDeferredCompile: typeof interceptDeferredCompile
index: () => Chainable<number>
}
}
}
Cypress.Commands.add('interceptCompile', interceptCompile)
Cypress.Commands.add('interceptEvents', interceptEvents)
Cypress.Commands.add('interceptSpelling', interceptSpelling)
Cypress.Commands.add('waitForCompile', waitForCompile)
Cypress.Commands.add('interceptDeferredCompile', interceptDeferredCompile)
Cypress.Commands.add('index', { prevSubject: true }, subject => {
return cy.wrap(subject).invoke('index')
})