Vue Hubble
A better way to select elements for UI testing in Vue.
Vue Hubble makes it simple to add selectors (only in your testing environment) and target component elements in tests without worrying about collisions, extraneous classes, etc.
Install
yarn add -D vue-hubble# or npm i -D vue-hubble
; Vue;
Usage
Implementation
<!-- Resulting HTML when NODE_ENV === 'test' --> <!--(vue-hubble) attribute-selector--><!--//(vue-hubble) attribute-selector--> <!--(vue-hubble) class-selector--><!--//(vue-hubble) class-selector--> <!--(vue-hubble) id-selector--><!--//(vue-hubble) id-selector-->
Namespacing
Hubble gives you the ability to namespace all selectors in a given component. Namespacing is recursive up the component tree, ignoring missing or empty namespace values. This feature is enabled by default, but can be disabled via install options.
<!-- Form Component (child) --> <!-- Login Component (parent) --> <!-- Resulting HTML when NODE_ENV equals correct environment (see install options)--> <!--(vue-hubble) login--form--attribute-selector--><!--//(vue-hubble) login--form--attribute-selector-->
Writing Tests
;
Install Options
Name | Type | Default | Description |
---|---|---|---|
defaultSelectorType |
String |
attr |
Defines the selector type if not passed into the directive v-hubble:attr |
enableComments |
Boolean |
true |
Enables or disables comments around elements with hubble selectors |
enableDeepNamespacing |
Boolean |
true |
Enables or disables auto recursive namespacing |
environment |
String or Array |
test |
Defines the environment(s) in which these selectors are added |
prefix |
String |
Prefixes all selectors with the value and -- , if value exists. For example, if prefix = 'qa' , all selectors well begin withqa-- |
Lint
yarn lint
Test
yarn test
Build Dist
yarn build
How to Contribute
Pull Requests
- Fork the repository
- Create a new branch for each feature or improvement
- Send a pull request from each feature branch to the develop branch