Skip to content
This repository was archived by the owner on Dec 12, 2020. It is now read-only.

Commit 54dcc9c

Browse files
amirrustambahmutov
authored andcommitted
fix: add TOC to README. Closes #8 (#11)
* Add Table of Contents Closes #8 * Fix spacing in TOC. Love it!
1 parent 711c664 commit 54dcc9c

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

README.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,29 @@
1515

1616
* 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/).
1717

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+
<a name="install"/>
40+
1841
## Install
1942

2043
Requires [Node](https://nodejs.org/en/) version 6 or above.
@@ -23,6 +46,8 @@ Requires [Node](https://nodejs.org/en/) version 6 or above.
2346
npm install --save-dev cypress cypress-vue-unit-test
2447
```
2548

49+
<a name="use"/>
50+
2651
## Use
2752

2853
Before each test, inject your component to test
@@ -40,6 +65,8 @@ describe('My Vue', () => {
4065

4166
See examples below for details.
4267

68+
<a name="options"/>
69+
4370
### Options
4471

4572
See [cypress/integration/options-spec.js](cypress/integration/options-spec.js)
@@ -78,6 +105,8 @@ const options = {
78105
beforeEach(mountVue(/* my Vue code */, options))
79106
```
80107

108+
<a name="global-vue-extensions"/>
109+
81110
### Global Vue extensions
82111

83112
You can pass extensions (global components, mixins, modules to use)
@@ -150,6 +179,8 @@ it('calls mixin "created" method', () => {
150179
See [Vue global mixin docs](https://vuejs.org/v2/guide/mixins.html#Global-Mixin)
151180
and [mixin-spec.js](cypress/integration/mixin-spec.js)
152181

182+
<a name="intro-example"/>
183+
153184
### The intro example
154185

155186
Take a look at the first Vue v2 example:
@@ -215,6 +246,8 @@ the reference `Cypress.vue.$data` and via GUI. The full power of the
215246

216247
![Hello world tested](images/spec.png)
217248

249+
<a name="list-example"/>
250+
218251
### The list example
219252

220253
There is a list example next in the Vue docs.
@@ -280,6 +313,8 @@ describe('Declarative rendering', () => {
280313

281314
![List tested](images/list-spec.png)
282315

316+
<a name="handling-user-input"/>
317+
283318
### Handling User Input
284319

285320
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!
346381

347382
![Reverse input](images/reverse-spec.gif)
348383

384+
<a name="component-example"/>
385+
349386
### Component example
350387

351388
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
@@ -401,6 +438,8 @@ describe('Several components', () => {
401438
})
402439
```
403440

441+
<a name="spying-example"/>
442+
404443
### Spying example
405444

406445
Button counter component is used in several Vue doc examples
@@ -472,6 +511,8 @@ and is emitting an event.
472511

473512
[cypress.io]: https://www.cypress.io/
474513

514+
<a name="xhr-spying-stubbing"/>
515+
475516
### XHR spying and stubbing
476517

477518
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).
@@ -501,14 +542,20 @@ it('can display mock XHR response', () => {
501542
})
502543
```
503544

545+
<a name="spying-window-alert"/>
546+
504547
### Spying on `window.alert`
505548

506549
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)
507550

551+
<a name="bundling"/>
552+
508553
## Bundling
509554

510555
How do we load this Vue file into the testing code? Using webpack preprocessor.
511556

557+
<a name="short-way"/>
558+
512559
### Short way
513560

514561
Your project probably already has `webpack.config.js` setup to transpile
@@ -527,6 +574,8 @@ module.exports = on => {
527574

528575
Cypress should be able to import `.vue` files in the tests
529576

577+
<a name="manual"/>
578+
530579
### Manual
531580

532581
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', () => {
582631
})
583632
```
584633

634+
<a name="#faq"/>
635+
585636
## FAQ
586637

587638
- If your component's static assets are not loading, you probably need

0 commit comments

Comments
 (0)