You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 12, 2020. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+51Lines changed: 51 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,29 @@
15
15
16
16
* How is this different from [vue-test-utils](https://vue-test-utils.vuejs.org/en/)? It is similar in functionality BUT runs the component in the real browser with full power of Cypress E2E test runner: [live GUI, full API, screen recording, CI support, cross-platform](https://www.cypress.io/features/).
17
17
18
+
## Table of Contents
19
+
20
+
[Install](#install)
21
+
22
+
[Use](#use)
23
+
-[Options](#options)
24
+
-[Global Vue Extensions](#global-vue-extensions)
25
+
-[The Intro Example](#intro-example)
26
+
-[The List Example](#list-example)
27
+
-[Handling User Input](#handling-user-input)
28
+
-[Component Example](#component-example)
29
+
-[Spying Example](#spying-example)
30
+
-[XHR Spying and Stubbing](#xhr-spying-stubbing)
31
+
-[Spying On `window.alert`](#spying-window-alert)
32
+
33
+
[Bundling](#bundling)
34
+
-[Short Way](#short-way)
35
+
-[Manual](#manual)
36
+
37
+
[FAQ](#faq)
38
+
39
+
<aname="install"/>
40
+
18
41
## Install
19
42
20
43
Requires [Node](https://nodejs.org/en/) version 6 or above.
@@ -23,6 +46,8 @@ Requires [Node](https://nodejs.org/en/) version 6 or above.
The next section in the Vue docs starts with [reverse message example](https://vuejs.org/v2/guide/#Handling-User-Input).
@@ -346,6 +381,8 @@ because it is really running!
346
381
347
382

348
383
384
+
<aname="component-example"/>
385
+
349
386
### Component example
350
387
351
388
Let us test a complex example. Let us test a [single file Vue component](https://vuejs.org/v2/guide/single-file-components.html). Here is the [Hello.vue](Hello.vue) file
Button counter component is used in several Vue doc examples
@@ -472,6 +511,8 @@ and is emitting an event.
472
511
473
512
[cypress.io]: https://www.cypress.io/
474
513
514
+
<aname="xhr-spying-stubbing"/>
515
+
475
516
### XHR spying and stubbing
476
517
477
518
The mount function automatically wraps XMLHttpRequest giving you an ability to intercept XHR requests your component might do. For full documentation see [Network Requests](https://on.cypress.io/network-requests). In this repo see [components/AjaxList.vue](components/AjaxList.vue) and the corresponding tests [cypress/integration/ajax-list-spec.js](cypress/integration/ajax-list-spec.js).
Calls to `window.alert` are automatically recorded, but do not show up. Instead you can spy on them, see [AlertMessage.vue](components/AlertMessage.vue) and its test [cypress/integration/alert-spec.js](cypress/integration/alert-spec.js)
507
550
551
+
<aname="bundling"/>
552
+
508
553
## Bundling
509
554
510
555
How do we load this Vue file into the testing code? Using webpack preprocessor.
511
556
557
+
<aname="short-way"/>
558
+
512
559
### Short way
513
560
514
561
Your project probably already has `webpack.config.js` setup to transpile
@@ -527,6 +574,8 @@ module.exports = on => {
527
574
528
575
Cypress should be able to import `.vue` files in the tests
529
576
577
+
<aname="manual"/>
578
+
530
579
### Manual
531
580
532
581
Using [@cypress/webpack-preprocessor](https://github.com/cypress-io/cypress-webpack-preprocessor#readme) and [vue-loader](https://github.com/vuejs/vue-loader).
@@ -582,6 +631,8 @@ describe('Hello.vue', () => {
582
631
})
583
632
```
584
633
634
+
<aname="#faq"/>
635
+
585
636
## FAQ
586
637
587
638
- If your component's static assets are not loading, you probably need
0 commit comments