1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- import 'cypress-axe'
- import { mount } from '@cypress/vue2'
- Cypress.Commands.add('mount', (component, optionsOrProps) => {
- let instance = null
- const oldMounted = component?.mounted || false
-
-
- component.mounted = function() {
-
- instance = this
- if (oldMounted) {
- oldMounted.call(instance)
- }
- }
-
- return mount(component, optionsOrProps).then(() => {
- return cy.wrap(instance).as('component')
- })
- })
- Cypress.Commands.add('mockInitialState', (app: string, key: string, value: any) => {
- cy.document().then(($document) => {
- const input = $document.createElement('input')
- input.setAttribute('type', 'hidden')
- input.setAttribute('id', `initial-state-${app}-${key}`)
- input.setAttribute('value', btoa(JSON.stringify(value)))
- $document.body.appendChild(input)
- })
- })
- Cypress.Commands.add('unmockInitialState', (app?: string, key?: string) => {
- cy.document().then(($document) => {
- $document.querySelectorAll('body > input[type="hidden"]' + (app ? `[id="initial-state-${app}-${key}"]` : ''))
- .forEach((node) => $document.body.removeChild(node))
- })
- })
|