2.7.1 • Published 4 years ago

@laura-wert/vue-test-helpers v2.7.1

Weekly downloads
7
License
MIT
Repository
-
Last release
4 years ago

Build Status Codacy Badge Codacy Badge

vue-test-helpers

tslint jsrules can be set to true when the following PR is released https://github.com/palantir/tslint/pull/3641

Installation

Cypress

If you want to be able to use the vue app in the cypress tests you need to add the vue app to the window object. This can be done by installing vue-test-helpers as a plugin and running the following code:

import { addAppToWindow } from '@laura-wert/vue-test-helpers'
import IVue, { ComponentOptions } from 'vue'

// is not a plugin but adds app to the window object so it can easily be used in cypress tests
export default <V extends IVue>({ app }: { app: ComponentOptions<V> }): void => {
  addAppToWindow(app)
}

This package also contains a few cypress commands which can be used in you project by extending cypress as follows:

     import { extendCypress } from '@laura-wert/vue-test-helpers'
     
     extendCypress(Cypress, cy)

If you want to use the extra cypress commands in a typescript project, then you need to declare the following commands on the Chainable interface in the cypress namespace:

/* tslint:disable-next-line */
declare namespace Cypress {
  // @ts-ignore
  import { Store } from 'vuex'

  /* tslint:disable interface-name no-any */
  interface Chainable<Subject = any> {
      getByName<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>

      findByName<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>

      getInput<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>
    
      findInput<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>
      
      getField<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>
          
      findField<E extends Node = HTMLElement>(...parts: string[]): Chainable<JQuery<E>>
            
      shouldHaveValidationError<E extends Node = HTMLElement>(errorMessage: string): void
      
      shouldNotHaveValidationError<E extends Node = HTMLElement>(): void

      shouldShowNotification<E extends Node = HTMLElement>(
        errorMessage: string,
        index?: number,
      ): void

      loadStore(): Promise<Store>

      selectOption(labelOrIndex: string | string[] | number | number[]): void
  }
}
2.7.1

4 years ago

3.0.0

4 years ago

2.7.0

4 years ago

2.6.0

5 years ago

2.5.9

5 years ago

2.5.8

5 years ago

2.5.7

5 years ago

2.5.6

5 years ago

2.5.5

5 years ago

2.5.4

5 years ago

2.5.3

5 years ago

2.5.2

5 years ago

2.5.1

5 years ago

2.4.1

5 years ago

2.4.0

5 years ago

2.3.0

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago