frontend/src/directives/cypress.ts
dpschen 981babd691 fix: remove mentioning of context (#1017)
Co-authored-by: Dominik Pschenitschni <mail@celement.de>
Reviewed-on: vikunja/frontend#1017
Reviewed-by: konrad <k@knt.li>
Co-authored-by: dpschen <dpschen@noreply.kolaente.de>
Co-committed-by: dpschen <dpschen@noreply.kolaente.de>
2021-11-22 21:36:17 +00:00

24 lines
360 B
TypeScript

import {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