Skip to content

Commit 596511e

Browse files
Merge branch 'master' of https://github.com/vuejs/vuejs.org
2 parents ca15810 + 69106b2 commit 596511e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+52496
-233
lines changed

.github/pull_request_template.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
Note
22
====
3-
We're currently in the process of migrating Vue's documentation to v3. To ensure smooth progress, only PR's that fix critical bugs and/or misinformation will be accepted. If yours is not one of them, consider [creating an issue](https://github.com/vuejs/vuejs.org/issues/new) instead and we will label it as `post-3.0` for later tackling.
3+
This repository is for Vue 1.x and 2.x only. Issues and pull requests related to 3.x are managed in the v3 doc repo: https://github.com/vuejs/docs-next.

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# vuejs.org
22

3+
> Important: This repository is for Vue 1.x and 2.x only. Issues and pull requests related to 3.x are managed in the [v3 doc repo](https://github.com/vuejs/docs-next).
4+
35
This site is built with [hexo](http://hexo.io/). Site content is written in Markdown format located in `src`. Pull requests welcome!
46

57
## Writing

src/v2/api/index.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1382,10 +1382,14 @@ type: api
13821382
13831383
- **Read only**
13841384
1385+
- **Reactive?** No
1386+
13851387
- **Details:**
13861388
13871389
Used to programmatically access content [distributed by slots](../guide/components.html#Content-Distribution-with-Slots). Each [named slot](../guide/components.html#Named-Slots) has its own corresponding property (e.g. the contents of `v-slot:foo` will be found at `vm.$slots.foo`). The `default` property contains either nodes not included in a named slot or contents of `v-slot:default`.
13881390
1391+
Please note that slots are **not** reactive. If you need a component to re-render based on changes to data passed to a slot, we suggest considering a different strategy that relies on a reactive instance option, such as `props` or `data`.
1392+
13891393
**Note:** `v-slot:foo` is supported in v2.6+. For older versions, you can use the [deprecated syntax](../guide/components-slots.html#Deprecated-Syntax).
13901394
13911395
Accessing `vm.$slots` is most useful when writing a component with a [render function](../guide/render-function.html).

src/v2/guide/comparison.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ React is renowned for its steep learning curve. Before you can really get starte
111111
While Vue scales up just as well as React, it also scales down just as well as jQuery. That's right - to get started, all you have to do is drop a single script tag into the page:
112112

113113
``` html
114-
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
114+
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
115115
```
116116

117117
Then you can start writing Vue code and even ship the minified version to production without feeling guilty or having to worry about performance problems.

src/v2/guide/components-dynamic-async.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ new Vue({
106106
background: #f0f0f0;
107107
margin-bottom: -1px;
108108
margin-right: -1px;
109+
overflow-anchor: none;
109110
}
110111
.dynamic-component-demo-tab-button:hover {
111112
background: #e0e0e0;

src/v2/guide/components-props.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ This pattern allows you to use base components more like raw HTML elements, with
347347

348348
```html
349349
<base-input
350+
label="Username:"
350351
v-model="username"
351352
required
352353
placeholder="Enter your username"

src/v2/guide/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ The easiest way to try out Vue.js is using the [Hello World example](https://cod
2424

2525
``` html
2626
<!-- development version, includes helpful console warnings -->
27-
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
27+
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
2828
```
2929

3030
or:
3131

3232
``` html
3333
<!-- production version, optimized for size and speed -->
34-
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
34+
<script src="https://cdn.jsdelivr.net/npm/vue@2"></script>
3535
```
3636

3737
The [Installation](installation.html) page provides more options of installing Vue. Note: We **do not** recommend that beginners start with `vue-cli`, especially if you are not yet familiar with Node.js-based build tools.

src/v2/guide/installation.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ Simply download and include with a script tag. `Vue` will be registered as a glo
4141
For prototyping or learning purposes, you can use the latest version with:
4242

4343
``` html
44-
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
44+
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
4545
```
4646

4747
For production, we recommend linking to a specific version number and build to avoid unexpected breakage from newer versions:
@@ -84,7 +84,7 @@ Vue provides an [official CLI](https://github.com/vuejs/vue-cli) for quickly sca
8484

8585
## Explanation of Different Builds
8686

87-
In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/vue/dist/) you will find many different builds of Vue.js. Here's an overview of the difference between them:
87+
In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/vue@2/dist/) you will find many different builds of Vue.js. Here's an overview of the difference between them:
8888

8989
| | UMD | CommonJS | ES Module (for bundlers) | ES Module (for browsers) |
9090
| --- | --- | --- | --- | --- |
@@ -101,7 +101,7 @@ In the [`dist/` directory of the NPM package](https://cdn.jsdelivr.net/npm/vue/d
101101

102102
- **Runtime**: code that is responsible for creating Vue instances, rendering and patching virtual DOM, etc. Basically everything minus the compiler.
103103

104-
- **[UMD](https://github.com/umdjs/umd)**: UMD builds can be used directly in the browser via a `<script>` tag. The default file from jsDelivr CDN at [https://cdn.jsdelivr.net/npm/vue](https://cdn.jsdelivr.net/npm/vue) is the Runtime + Compiler UMD build (`vue.js`).
104+
- **[UMD](https://github.com/umdjs/umd)**: UMD builds can be used directly in the browser via a `<script>` tag. The default file from jsDelivr CDN at [https://cdn.jsdelivr.net/npm/vue@2](https://cdn.jsdelivr.net/npm/vue@2) is the Runtime + Compiler UMD build (`vue.js`).
105105

106106
- **[CommonJS](http://wiki.commonjs.org/wiki/Modules/1.1)**: CommonJS builds are intended for use with older bundlers like [browserify](http://browserify.org/) or [webpack 1](https://webpack.github.io). The default file for these bundlers (`pkg.main`) is the Runtime only CommonJS build (`vue.runtime.common.js`).
107107

src/v2/guide/instance.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ A Vue application consists of a **root Vue instance** created with `new Vue`, op
2424
Root Instance
2525
└─ TodoList
2626
├─ TodoItem
27-
│ ├─ DeleteTodoButton
28-
│ └─ EditTodoButton
27+
│ ├─ TodoButtonDelete
28+
│ └─ TodoButtonEdit
2929
└─ TodoListFooter
30-
├─ ClearTodosButton
30+
├─ TodosButtonClear
3131
└─ TodoListStatistics
3232
```
3333

src/v2/guide/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ These expressions will be evaluated as JavaScript in the data scope of the owner
9898
{{ if (ok) { return message } }}
9999
```
100100

101-
<p class="tip">Template expressions are sandboxed and only have access to a [whitelist of globals](https://github.com/vuejs/vue/blob/v2.6.10/src/core/instance/proxy.js#L9) such as `Math` and `Date`. You should not attempt to access user defined globals in template expressions.</p>
101+
<p class="tip">Template expressions are sandboxed and only have access to a [whitelist of globals](https://github.com/vuejs/vue/blob/v2.6.10/src/core/instance/proxy.js#L9) such as `Math` and `Date`. You should not attempt to access user-defined globals in template expressions.</p>
102102

103103
## Directives
104104

@@ -167,7 +167,7 @@ Dynamic argument expressions have some syntax constraints because certain charac
167167

168168
The workaround is to either use expressions without spaces or quotes, or replace the complex expression with a computed property.
169169

170-
When using in-DOM templates (templates directly written in an HTML file), you should also avoid naming keys with uppercase characters, as browsers will coerce attribute names into lowercase:
170+
When using in-DOM templates (i.e., templates written directly in an HTML file), you should also avoid naming keys with uppercase characters, as browsers will coerce attribute names into lowercase:
171171

172172
``` html
173173
<!--

src/v2/guide/team.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,19 +412,19 @@ order: 803
412412
languages: ['hi', 'en'],
413413
work: {
414414
role: 'Software Engineer',
415-
org: 'Myntra',
416-
orgUrl: 'https://www.myntra.com/'
415+
org: 'Grammarly',
416+
orgUrl: 'https://grammarly.com/'
417417
},
418418
github: 'znck',
419419
twitter: 'znck0',
420420
reposOfficial: [
421421
'rollup-plugin-vue', 'vue-issue-helper'
422422
],
423423
reposPersonal: [
424-
'keynote', 'bootstrap-for-vue', 'vue-interop'
424+
'vue-developer-experience', 'prop-types', 'grammarly'
425425
],
426426
links: [
427-
'https://znck.me', 'https://www.codementor.io/znck'
427+
'https://znck.me'
428428
]
429429
},
430430
{
@@ -795,6 +795,7 @@ order: 803
795795
role: 'Organizer',
796796
org: 'VueConf US'
797797
},
798+
imageUrl:'https://pbs.twimg.com/profile_images/1541624512/profile-pic-09-11-2011_400x400.png',
798799
twitter: 'prpatel',
799800
links: [
800801
'https://us.vuejs.org/'
@@ -809,6 +810,7 @@ order: 803
809810
role: 'Organizer',
810811
org: 'VueConf US'
811812
},
813+
imageUrl:'https://pbs.twimg.com/profile_images/916531463905992706/MNvTkO5K_400x400.jpg',
812814
twitter: 'vincentmayers',
813815
links: [
814816
'https://us.vuejs.org/'
@@ -823,6 +825,7 @@ order: 803
823825
role: 'Creator',
824826
org: 'Vue.js Amsterdam'
825827
},
828+
imageUrl: 'https://pbs.twimg.com/profile_images/1123492769299877888/aviXE_M5_400x400.jpg',
826829
twitter: 'lukevscostas',
827830
linkedin: 'luke-kenneth-thomas-578b3916a',
828831
links: [
@@ -838,6 +841,7 @@ order: 803
838841
role: 'Event Manager',
839842
org: 'Vue.js Amsterdam'
840843
},
844+
imageUrl:'https://pbs.twimg.com/profile_images/1110510517951627269/LDzDyd4N_400x400.jpg',
841845
twitter: 'josgerards88',
842846
linkedin: 'josgerards',
843847
links: [

src/v2/guide/testing.md

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
---
2+
title: Testing
3+
type: guide
4+
order: 402
5+
---
6+
7+
## Introduction
8+
9+
When it comes to building reliable applications, tests can play a critical role in an individual or team's ability to build new features, refactor code, fix bugs, etc. While there are many schools of thought with testing, there are three categories often discussed in the context of web applications:
10+
11+
- Unit Testing
12+
- Component Testing
13+
- End-To-End (E2E) Testing
14+
15+
This section aims to provide guidance to navigating the testing ecosystem and choosing the right tools for your Vue application or component library.
16+
17+
## Unit Testing
18+
19+
### Introduction
20+
21+
Unit tests allow you to test individual units of code in isolation. The purpose of unit testing is to provide developers with confidence in their code. By writing thorough, meaningful tests, you achieve the confidence that as new features are built or your code is refactored your application will remain functional and stable.
22+
23+
Unit testing a Vue application does not significantly differ from testing other types of applications.
24+
25+
### Choosing Your Framework
26+
27+
Since unit testing advice is often framework-agnostic, here are some basic guidelines to keep in mind when evaluating which unit testing tool is best for your application.
28+
29+
#### First-class error reporting
30+
31+
When tests fail, it is critical that your unit testing framework provides useful errors. This is the job of the assertion library. An assertion with high-quality error messages helps minimize the amount of time it takes to debug the problem. In addition to simply telling you what test is failing, assertion libraries provide context for why a test fails, e.g., what is expected vs what was received.
32+
33+
Some unit testing frameworks, like Jest, include assertion libraries. Others, like Mocha, require you to install assertion libraries separately (usually Chai).
34+
35+
#### Active community and team
36+
37+
Since the majority of unit testing frameworks are open-source, having a community that is active can be critical to some teams that will be maintaining their tests for a long period of time and needs to ensure that a project will be actively maintained. In addition, having an active community has the benefit of providing more support whenever you run into issues.
38+
39+
### Frameworks
40+
41+
While there are many tools in the ecosystem, here are some common unit testing tools that are being used in the Vue.js ecosystem.
42+
43+
#### Jest
44+
45+
Jest is a JavaScript test framework that is focused on simplicity. One of its unique features is the ability to take snapshots of tests in order to provide an alternative means of verifying units of your application.
46+
47+
**Resources:**
48+
49+
- [Official Jest Website](https://jestjs.io)
50+
- [Official Vue 2 CLI Plugin - Jest](https://cli.vuejs.org/core-plugins/unit-jest.html)
51+
52+
#### Mocha
53+
54+
Mocha is a JavaScript test framework that is focused on being flexible. Because of this flexibility, it allows you to choose different libraries to fulfill other common features such as spying (e.g., Sinon) and assertions (e.g., Chai). Another unique feature of Mocha is that it can also execute tests in the browser in addition to Node.js.
55+
56+
**Resources:**
57+
58+
- [Official Mocha Website](https://mochajs.org)
59+
- [Official Vue CLI Plugin - Mocha](https://cli.vuejs.org/core-plugins/unit-mocha.html)
60+
61+
## Component Testing
62+
63+
### Introduction
64+
65+
To test most Vue components, they must be mounted to the DOM (either virtual or real) in order to fully assert that they are working. This is another framework-agnostic concept. As a result, component testing frameworks were created to give users the ability to do this in a reliable way while also providing Vue-specific conveniences such as integrations for Vuex, Vue Router, and other Vue plugins.
66+
67+
### Choosing Your Framework
68+
69+
The following section provides guidelines on things to keep in mind when evaluating which component testing framework is best for your application.
70+
71+
#### Optimal compatibility with the Vue ecosystem
72+
73+
It should be no surprise that one of the first criteria is that a component testing library should have is being as compatible with the Vue ecosystem as possible. While this may seem comprehensive, some key integration areas to keep in mind include single file components (SFCs), Vuex, Vue Router, and any other Vue specific plugins that your application relies on.
74+
75+
#### First-class error reporting
76+
77+
When tests fail, it is critical that your component testing framework provides useful error logs that help to minimize the amount of time it takes to debug the problem. In addition to simply telling you what test fails, they should also provides context for why a test fails, e.g., what is expected vs what was received.
78+
79+
### Recommendations
80+
81+
#### Vue Testing Library (@testing-library/vue)
82+
83+
Vue Testing Library is a set of tools focused on testing components without relying on implementation details. Built with accessibility in mind, its approach also makes refactoring a breeze.
84+
85+
Its guiding principle is that the more tests resemble the way software is used, the more confidence they can provide.
86+
87+
**Resources:**
88+
89+
- [Official Vue Testing Library Website](https://testing-library.com/docs/vue-testing-library/intro)
90+
91+
#### Vue Test Utils
92+
93+
Vue Test Utils is the official low-level component testing library that was written to provide users access to Vue specific APIs. If you are new to testing Vue applications, we would recommend using Vue Testing Library, which is an abstraction over Vue Test Utils.
94+
95+
**Resources**
96+
97+
- [Official Vue Test Utils Documentation](https://vue-test-utils.vuejs.org)
98+
- [Vue Testing Handbook](https://lmiller1990.github.io/vue-testing-handbook/#what-is-this-guide) by Lachlan Miller
99+
- [Cookbook: Unit Testing Vue Components](https://vuejs.org/v2/cookbook/unit-testing-vue-components.html)
100+
101+
## End-to-End (E2E) Testing
102+
103+
### Introduction
104+
105+
While unit tests provide developers with some degree of confidence, unit and component tests are limited in their abilities to provide holistic coverage of an application when deployed to production. As a result, end-to-end (E2E) tests provide coverage on what is arguably the most important aspect of an application: what happens when users actually use your applications.
106+
107+
In other words, E2E tests validate all of the layers in your application. This not only includes your frontend code, but all associated backend services and infrastructure that are more representative of the environment that your users will be in. By testing how user actions impact your application, E2E tests are often the key to higher confidence in whether an application is functioning properly or not.
108+
109+
### Choosing Your Framework
110+
111+
While end-to-end (E2E) testing on the web has gained a negative reputation for unreliable (flaky) tests and slowing down development processes, modern E2E tools have made strides forward to create more reliable, interactive, and useful tests. When choosing an E2E testing framework, the following sections provide some guidance on things to keep in mind when choosing a testing framework for your application.
112+
113+
#### Cross-browser testing
114+
115+
One of the primary benefits that end-to-end (E2E) testing is known for is its ability to test your application across multiple browsers. While it may seem desirable to have 100% cross-browser coverage, it is important to note that cross browser testing has diminishing returns on a team's resources due the additional time and machine power required to run them consistently. As a result, it is important to be mindful of this trade-off when choosing the amount of cross-browser testing your application needs.
116+
117+
<p class="tip">A recent development in E2E for catching browser-specific issues is using application monitoring and error reporting tools (e.g., Sentry, LogRocket, etc.) for browsers that are not as commonly used (e.g., < IE11, older Safari versions, etc.).</p>
118+
119+
#### Faster feedback loops
120+
121+
One of the primary problems with end-to-end (E2E) tests and development is that running the entire suite takes a long time. Typically, this is only done in continuous integration and deployment (CI/CD) pipelines. Modern E2E testing frameworks have helped to solve this by adding features like parallelization, which allows for CI/CD pipelines to often run magnitudes faster than before. In addition, when developing locally, the ability to selectively run a single test for the page you are working on while also providing hot reloading of tests can help to boost a developer's workflow and productivity.
122+
123+
#### First class debugging experience
124+
125+
While developers have traditionally relied on scanning logs in a terminal window to help determine what went wrong in a test, modern end-to-end (E2E) test frameworks allow developers to leverage tools that they are already familiar with, e.g. browser developer tools.
126+
127+
#### Visibility in headless mode
128+
129+
When end-to-end (E2E) tests are run in continuous integration / deployment pipelines, they are often run in headless browsers (i.e., no visible browser is opened for the user to watch). As a result, when errors occur, a critical feature that modern E2E testing frameworks provide 1st class support for is the ability to see snapshots and/or videos of your applications during various testing stages in order to provide insight into why errors are happening. Historically, it was tedious to maintain these integrations.
130+
131+
### Recommendations
132+
133+
While there are many tools in the ecosystem, here are some common end-to-end (E2E) testing frameworks that are being used in the Vue.js ecosystem.
134+
135+
#### Cypress.io
136+
137+
Cypress.io is a testing framework that aims to enhance developer productivity by enabling developers to reliably test their applications while providing a first class developer experience.
138+
139+
**Resources**
140+
141+
- [Cypress' Official Website](https://www.cypress.io)
142+
- [Official Vue CLI Cypress Plugin](https://cli.vuejs.org/core-plugins/e2e-cypress.html)
143+
- [Cypress Testing Library](https://github.com/testing-library/cypress-testing-library)
144+
145+
#### Nightwatch.js
146+
147+
Nightwatch.js is an end-to-end testing framework that can be used to test web applications and websites, as well as Node.js unit and integration testing.
148+
149+
**Resources:**
150+
151+
- [Nightwatch's Official Website](https://nightwatchjs.org)
152+
- [Official Vue CLI Nightwatch Plugin](https://cli.vuejs.org/core-plugins/e2e-nightwatch.html)
153+
154+
#### Puppeteer
155+
156+
Puppeteer is a Node library that provides a high-level API to control the browser and can pair with other test runners (e.g., Jest) to test your application.
157+
158+
**Resources:**
159+
160+
- [Puppeteer's Official Website](https://pptr.dev)
161+
162+
#### TestCafe
163+
164+
TestCafe is a Node.js based end-to-end framework that aims to provide easy setup so that developers can focus on creating tests that are easy to write and reliable.
165+
166+
**Resources:**
167+
168+
- [TestCafe's Official Website](https://devexpress.github.io/testcafe/)

0 commit comments

Comments
 (0)