docs: babel, cypress, nightwatch

This commit is contained in:
Evan You
2018-02-08 16:52:47 -05:00
parent caaeaab1f7
commit 7e058eab23
5 changed files with 162 additions and 2 deletions

View File

@@ -1,3 +1,46 @@
# @vue/babel-preset-app
> babel-preset-app for vue-cli
This is the default Babel preset used in all Vue CLI projects.
## Included
- [babel-preset-env](https://github.com/babel/babel/tree/master/packages/babel-preset-env)
- `modules: false`
- auto set to `'commonjs'` in Jest tests
- [`useBuiltIns: 'usage'`](https://github.com/babel/babel/tree/master/packages/babel-preset-env#usebuiltins-usage)
- ensures polyfills are imported on-demand
- `targets` is determined:
- using `browserslist` field in `package.json` when building for browsers
- set to `{ node: 'current' }` when running unit tests in Node.js
- [@babel/plugin-transform-runtime](https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-runtime)
- Only enabled for helpers since polyfills are handled by `babel-preset-env`
- [dynamic import syntax](https://github.com/tc39/proposal-dynamic-import)
- [Object rest spread](https://github.com/tc39/proposal-object-rest-spread)
- [babel-preset-stage-2](https://github.com/babel/babel/tree/master/packages/babel-preset-stage-2)
- Vue JSX support
- [@babel/plugin-syntax-jsx](https://github.com/babel/babel/tree/master/packages/babel-plugin-syntax-jsx)
- [babel-plugin-transform-vue-jsx](https://github.com/vuejs/babel-plugin-transform-vue-jsx)
- [babel-plugin-jsx-event-modifiers](https://github.com/nickmessing/babel-plugin-jsx-event-modifiers)
- [babel-plugin-jsx-v-model](https://github.com/nickmessing/babel-plugin-jsx-v-model)
## Options
- **modules**
Default:
- `false` when building with webpack
- `'commonjs'` when running tests in Jest.
Explicitly set `modules` option for `babel-preset-env`.
- **targets**
Default:
- determined from `browserslist` field in `package.json` when building for browsers
- set to `{ node: 'current' }` when running unit tests in Node.js
Explicitly set `targets` option for `babel-preset-env`.
- **jsx**
Default: `true`. Set to `false` to disable JSX support.

View File

@@ -1,3 +1,39 @@
# @vue/cli-plugin-babel
> babel plugin for vue-cli
## Transpilation
Uses Babel 7 + `babel-loader` + [@vue/babel-preset-app](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/babel-preset-app) by default, but can be configured via `.babelrc` to use any other Babel presets or plugins.
By default, `babel-loader` is only applied to files inside `src` and `test` directories. If you wish to explicitly transpile a dependency module, you will need to configure webpack in `vue.config.js`:
``` js
module.exports = {
chainWebpack: config => {
config
.rule('js')
.include
.add(/module-to-transpile/)
}
}
```
## Injected Config Rules
- `config.rule('js')`
## Caching
[cache-loader](https://github.com/webpack-contrib/cache-loader) is enabled by default and cache is stored in `<projectRoot>/node_modules/.cache/cache-loader`.
## Parallelization
[thread-loader](https://github.com/webpack-contrib/thread-loader) is enabled by default when the machine has more than 1 CPU cores. This can be turned off by setting `parallel: false` in `vue.config.js`.
## Installing in an Already Created Project
``` sh
npm install -D @vue/cli-plugin-babel
vue invoke babel
```

View File

@@ -1,3 +1,47 @@
# @vue/cli-plugin-e2e-cypress
> e2e-cypress plugin for vue-cli
This adds E2E testing support using [Cypress](https://www.cypress.io/).
Cypress offers a rich interactive interface for running E2E tests, but currently only supports running the tests in Chromium. If you have a hard requirement on E2E testing in multiple browsers, consider using the Selenium-based [@vue/cli-plugin-e2e-nightwatch](https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-e2e-nightwatch).
## Injected Commands
### `vue-cli-service e2e`
run e2e tests headlessly with `cypress run`.
Options:
```
--url run e2e tests against given url instead of auto-starting dev server
-s, --spec runs a specific spec file. defaults to "all"
```
Additionally, [all Cypress CLI options for `cypress run` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-run).
### `vue-cli-service e2e:open`
run e2e tests in interactive mode with `cypress open`.
Options:
```
--url run e2e tests against given url instead of auto-starting dev server
```
Additionally, [all Cypress CLI options for `cypress open` are also supported](https://docs.cypress.io/guides/guides/command-line.html#cypress-open).
Both commands automatically starts a server in production mode to run the e2e tests against. If you want to run the tests multiple times without having to restart the server every time, you can start the server with `vue-cli-service serve --mode production` in one terminal, and then run e2e tests against that server using the `--url` option.
## Configuration
We've pre-configured Cypress to place most of the e2e testing related files under `<projectRoot>/test/e2e`. You can also check out [how to configure Cypress via `cypress.json`](https://docs.cypress.io/guides/references/configuration.html#Options).
## Installing in an Already Created Project
``` sh
npm install -D @vue/cli-plugin-e2e-cypress
vue invoke e2e-cypress
```

View File

@@ -1,3 +1,33 @@
# @vue/cli-plugin-e2e-nightwatch
> e2e-nightwatch plugin for vue-cli
## Injected Commands
### `vue-cli-service e2e`
run e2e tests with [NightwatchJS](nightwatchjs.org).
Options:
```
--url run e2e tests against given url instead of auto-starting dev server
-e, --env specify comma-delimited browser envs to run in (default: chrome)
-t, --test sepcify a test to run by name
-f, --filter glob to filter tests by filename
```
Additionally, [all Nightwatch CLI options are also supported](https://github.com/nightwatchjs/nightwatch/blob/master/lib/runner/cli/cli.js).
## Configuration
We've pre-configured Nightwatch to run with Chrome by default. If you wish to run e2e tests in additional browsers, you will need to add a `nightwatch.config.js` or `nightwatch.json` in your project root to configure additional browsers. The config will be merged into the [internal Nightwatch config](https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-plugin-e2e-nightwatch/nightwatch.config.js).
Consult Nightwatch docs for [configuration options](http://nightwatchjs.org/gettingstarted#settings-file) and how to [setup browser drivers](http://nightwatchjs.org/gettingstarted#browser-drivers-setup).
## Installing in an Already Created Project
``` sh
npm install -D @vue/cli-plugin-e2e-nightwatch
vue invoke e2e-nightwatch
```

View File

@@ -25,7 +25,14 @@ module.exports = (api, options) => {
// expose dev server url to tests
process.env.VUE_DEV_SERVER_URL = url
// expose user options to config file
process.env.VUE_NIGHTWATCH_USER_OPTIONS = JSON.stringify(options.nightwatch || {})
const fs = require('fs')
let userOptionsPath, userOptions
if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.config.js'))) {
userOptions = require(userOptionsPath)
} else if (fs.existsSync(userOptionsPath = api.resolve('nightwatch.json'))) {
userOptions = require(userOptionsPath)
}
process.env.VUE_NIGHTWATCH_USER_OPTIONS = JSON.stringify(userOptions || {})
rawArgs.push('--config', require.resolve('./nightwatch.config.js'))
if (rawArgs.indexOf('--env') === -1) {