vikunja-frontend/src/directives/cypress.ts

24 lines
365 B
TypeScript

import type {Directive} from 'vue'
declare global {
interface Window {
Cypress: object;
}
}
const cypressDirective: Directive = {
mounted(el, {value}) {
if (
(window.Cypress || import.meta.env.DEV) &&
value
) {
el.setAttribute('data-cy', value)
}
},
beforeUnmount(el) {
el.removeAttribute('data-cy')
},
}
export default cypressDirective