Files
vue-cli/packages/@vue/cli-plugin-e2e-cypress
Cédric Exbrayat 1ae53e5c95 fix: comment eslint disable in cypress config (#4910)
The current cypress config has a global eslint-disable:

typescript
```
/* eslint-disable import/no-extraneous-dependencies, global-require, arrow-body-style */
// const webpack = require('@cypress/webpack-preprocessor')
```

But this assumes that `eslint-import-plugin` is present, whereas this is only true when the selected preset is the Airbnb one.
In other cases, this fails `yarn lint` right away with:

```
error: Definition for rule 'import/no-extraneous-dependencies' was not found (import/no-extraneous-dependencies) at tests/e2e/plugins/index.js```

Even if using the Airbnb preset, the comment does not have any effect, as, by default, the `require` call is commented.

This commit now splits the rules disabling in two:

- one commented for the people using Airbnb and who will uncomment the require call below, as it is only useful for them.
- one activated that disables `arrow-body-style` as it will fail the linting for people using Airbnb preset with the current config.
2020-01-03 14:55:19 +08:00
..
2018-03-20 01:39:26 +01:00
2019-12-28 20:54:27 +08:00

@vue/cli-plugin-e2e-cypress

e2e-cypress plugin for vue-cli

This adds E2E testing support using Cypress.

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.

Injected Commands

  • vue-cli-service test:e2e

    Run e2e tests with cypress run.

    By default it launches Cypress in interactive mode with a GUI. If you want to run the tests in headless mode (e.g. for CI), you can do so with the --headless option.

    The command 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.

    Options:

    --headless run in headless mode without GUI
    --mode     specify the mode the dev server should run in. (default: production)
    --url      run e2e tests against given url instead of auto-starting dev server
    -s, --spec (headless only) runs a specific spec file. defaults to "all"
    

    Additionally:

    Examples :

    • Run Cypress in headless mode for a specific file: vue-cli-service test:e2e --headless --spec tests/e2e/specs/actions.spec.js

Configuration

We've pre-configured Cypress to place most of the e2e testing related files under <projectRoot>/tests/e2e. You can also check out how to configure Cypress via cypress.json.

Environment Variables

Cypress doesn't load .env files for your test files the same way as vue-cli does for your application code. Cypress supports a few ways to define env variables but the easiest one is to use .json files (either cypress.json or cypress.env.json) to define environment variables. Keep in mind those variables are accessible via Cypress.env function instead of regular process.env object.

Installing in an Already Created Project

vue add e2e-cypress