diff --git a/source/api/commands/exec.md b/source/api/commands/exec.md index 6120d6d7db..1a8a25bfec 100644 --- a/source/api/commands/exec.md +++ b/source/api/commands/exec.md @@ -29,7 +29,7 @@ cy.exec('npm run build') **{% fa fa-angle-right %} command** ***(String)*** -The system command to be executed from the project root (the directory that contains `cypress.json`). +The system command to be executed from the project root (the directory that contains the default `cypress.json` configuration file). **{% fa fa-angle-right %} options** ***(Object)*** @@ -156,7 +156,7 @@ A command must exit within the `execTimeout` or Cypress will kill the command's # Command Log -***List the contents of cypress.json*** +***List the contents of the default `cypress.json` configuration file*** ```javascript if (Cypress.platform === 'win32') { diff --git a/source/api/commands/readfile.md b/source/api/commands/readfile.md index 390740cf4f..78cffa2830 100644 --- a/source/api/commands/readfile.md +++ b/source/api/commands/readfile.md @@ -25,7 +25,7 @@ cy.readFile('menu.json') **{% fa fa-angle-right %} filePath** ***(String)*** -A path to a file within the project root (the directory that contains `cypress.json`). +A path to a file within the project root (the directory that contains the default `cypress.json` configuration file). **{% fa fa-angle-right %} encoding** ***(String)*** @@ -192,7 +192,7 @@ cy.readFile('some/nested/path/story.txt').should('eq', 'Once upon a time...') # Command Log -***List the contents of cypress.json*** +***List the contents of the default `cypress.json` configuration file*** ```javascript cy.readFile('cypress.json') diff --git a/source/api/commands/request.md b/source/api/commands/request.md index c74a15f240..5bd71647a8 100644 --- a/source/api/commands/request.md +++ b/source/api/commands/request.md @@ -37,11 +37,10 @@ cy.visit('http://localhost:8080/app') cy.request('users/1.json') // url is http://localhost:8080/users/1.json ``` -2. If you make a `cy.request()` prior to visiting a page, Cypress uses the host configured as the `baseUrl` property inside of `cypress.json`. +2. If you make a `cy.request()` prior to visiting a page, Cypress uses the host configured as the `baseUrl` property inside of of your {% url "configuration file" configuration %}. ```json // cypress.json - { "baseUrl": "http://localhost:1234" } diff --git a/source/api/commands/task.md b/source/api/commands/task.md index bcea90b8ea..41be8b6f74 100644 --- a/source/api/commands/task.md +++ b/source/api/commands/task.md @@ -249,7 +249,7 @@ If multiple task objects use the same key, the later registration will overwrite # Command Log -***List the contents of `cypress.json`*** +### List the contents of the default `cypress.json` configuration file ```javascript cy.task('readJson', 'cypress.json') diff --git a/source/api/commands/viewport.md b/source/api/commands/viewport.md index 21095958ab..1fa1f32143 100644 --- a/source/api/commands/viewport.md +++ b/source/api/commands/viewport.md @@ -181,7 +181,7 @@ When hovering over each command, Cypress will automatically display the snapshot By default, until you issue a `cy.viewport()` command, Cypress sets the width to `1000px` and the height to `660px` by default. -You can {% url 'change these default dimensions' configuration#Viewport %} by adding the following to your `cypress.json`: +You can {% url 'change these default dimensions' configuration#Viewport %} by adding the following to your configuration file (`cypress.json` by default): ```json { diff --git a/source/api/commands/visit.md b/source/api/commands/visit.md index d68bff2dc6..94fbc4d931 100644 --- a/source/api/commands/visit.md +++ b/source/api/commands/visit.md @@ -212,7 +212,7 @@ cy.visit('127.0.0.1:3000') // Visits http://127.0.0.1:3000 ### Cypress can optionally act as your web server -Cypress will automatically attempt to serve your files if you don't provide a host. The path should be relative to your project's root folder (where `cypress.json` is located). +Cypress will automatically attempt to serve your files if you don't provide a host. The path should be relative to your project's root folder (where the `cypress.json` file is generated by default). Having Cypress serve your files is useful in simple projects and example apps, but isn't recommended for real apps. It is always better to run your own server and provide the url to Cypress. @@ -222,9 +222,9 @@ cy.visit('app/index.html') ## Prefixes -### Visit is automatically prefixed with `baseUrl`. +### Visit is automatically prefixed with `baseUrl` -Configure `baseUrl` in the `cypress.json` file to prevent repeating yourself in every single `cy.visit()` command. Read more about {% url 'configuration' configuration %}. +Configure `baseUrl` in the your {% url 'configuration' configuration %} file (`cypress.json` by default) to prevent repeating yourself in every `cy.visit()` command. ```json { diff --git a/source/api/commands/writefile.md b/source/api/commands/writefile.md index f305646db6..e2a818a7d4 100644 --- a/source/api/commands/writefile.md +++ b/source/api/commands/writefile.md @@ -24,7 +24,7 @@ cy.writeFile('menu.json') **{% fa fa-angle-right %} filePath** ***(String)*** -A path to a file within the project root (the directory that contains `cypress.json`). +A path to a file within the project root (the directory that contains the default `cypress.json`). **{% fa fa-angle-right %} contents** ***(String, Array, or Object)*** diff --git a/source/api/cypress-api/config.md b/source/api/cypress-api/config.md index 240ba93461..3ebc285660 100644 --- a/source/api/cypress-api/config.md +++ b/source/api/cypress-api/config.md @@ -45,7 +45,7 @@ Set multiple configuration options with an object literal. ## No Arguments -### Get all configuration options +### Get all configuration options from {% url 'configuration' configuration %} file (`cypress.json` by default) ```json { @@ -62,7 +62,7 @@ Cypress.config() // => {defaultCommandTimeout: 10000, pageLoadTimeout: 30000, .. ## Name -### Return just a single configuration option value +### Return a single configuration option from {% url 'configuration' configuration %} file (`cypress.json` by default) ```json { @@ -76,7 +76,7 @@ Cypress.config('pageLoadTimeout') // => 60000 ## Name and Value -### Change the values of your configuration options from within tests +### Change the values of configuration options from configuration file (`cypress.json` by default) from within your tests {% note warning Scope %} Remember, any changes that you make to configuration using this API will only be in effect for the remainder of the tests _in the same spec file._ @@ -97,7 +97,7 @@ Cypress.config('viewportWidth') // => 800 ## Object -### Set multiple values by passing an object literal +### Override multiple options from configuration file (`cypress.json` by default) by passing an object literal ```json { diff --git a/source/api/cypress-api/custom-commands.md b/source/api/cypress-api/custom-commands.md index fc82683f05..40b055cd64 100644 --- a/source/api/cypress-api/custom-commands.md +++ b/source/api/cypress-api/custom-commands.md @@ -262,7 +262,7 @@ Cypress.Commands.overwrite('visit', (originalFn, url, options) => { {% note info %} We see many of our users creating their own `visitApp` command. We commonly see that all you're doing is swapping out base urls for `development` vs `production` environments. -This is usually unnecessary because Cypress is already configured to swap out baseUrl's that both `cy.visit()` and `cy.request()` use. Just set the `baseUrl` config property in `cypress.json` and override it with environment variable `CYPRESS_BASE_URL`. +This is usually unnecessary because Cypress is already configured to swap out baseUrl's that both `cy.visit()` and `cy.request()` use. Set the `baseUrl` configuration property in your {% url "configuration" configuration %} file (`cypress.json` by default) and override it with environment variable `CYPRESS_BASE_URL`. For more complex use cases feel free to overwrite existing commands. {% endnote %} diff --git a/source/api/cypress-api/env.md b/source/api/cypress-api/env.md index 72c569e250..84d066ab68 100644 --- a/source/api/cypress-api/env.md +++ b/source/api/cypress-api/env.md @@ -41,10 +41,9 @@ Set multiple environment variables with an object literal. ## No Arguments -**Get all environment variables.** +### Get all environment variables from configuration file (`cypress.json` by default) -```javascript -// cypress.json +```json { "env": { "foo": "bar", @@ -59,10 +58,9 @@ Cypress.env() // => {foo: "bar", baz: "quux"} ## Name -**Return a single environment variable value.** +### Return a single environment variable from configuration file (`cypress.json` by default) -```javascript -// cypress.json +```json { "env": { "foo": "bar", @@ -78,14 +76,13 @@ Cypress.env('baz') // => quux ## Name and Value -**Cypress allows you to change the values of your environment variables from within your tests.** +### Change environment variables from configuration file (`cypress.json` by default) from within your tests {% note warning Scope %} Remember, any changes that you make to environment variables using this API will only be in effect for the remainder of the tests _in the same spec file._ {% endnote %} -```javascript -// cypress.json +```json { "env": { "foo": "bar", @@ -102,7 +99,7 @@ Cypress.env('host') // => http://server.dev.local ## Object -**You can set multiple values by passing an object literal.** +### Override multiple values from configuration file (`cypress.json` by default) by passing an object literal. ```javascript // cypress.json @@ -140,6 +137,7 @@ module.exports = (on, config) => { return config } ``` + ```js // cypress/integration/secrets_spec.js describe('Environment variable set in plugin', () => { @@ -158,17 +156,17 @@ describe('Environment variable set in plugin', () => { # Notes -**Why would I ever need to use environment variables?** +## Why would I ever need to use environment variables? The {% url 'Environment Variables' environment-variables %} guide explains common use cases. -**Can I pass in environment variables from the command line?** +## Can I pass in environment variables from the command line? Yes. You can do that and much more. The {% url 'Environment Variables' environment-variables %} guide explains the other ways you can set environment variables for your tests. -**Why is it `Cypress.env` and not `cy.env`?** +## Why is it `Cypress.env` and not `cy.env`? As a rule of thumb anything you call from `Cypress` affects global state. Anything you call from `cy` affects local state. diff --git a/source/examples/examples/recipes.md b/source/examples/examples/recipes.md index b6d264eccd..ea360bc3a3 100644 --- a/source/examples/examples/recipes.md +++ b/source/examples/examples/recipes.md @@ -88,4 +88,4 @@ Recipe | Description {% url 'Visual Regression Testing' https://github.com/mjhea0/cypress-visual-regression %} | Adding visual regression testing to Cypress {% url 'Code coverage' https://github.com/paulfalgout/cypress-coverage-example %} | Cypress with Coverage reports {% url 'Cucumber' https://github.com/TheBrainFamily/cypress-cucumber-example %} | Example usage of Cypress with Cucumber -{% url 'Jest' https://github.com/TheBrainFamily/jest-runner-cypress-example %} | Example for the jest-runner-cypress \ No newline at end of file +{% url 'Jest' https://github.com/TheBrainFamily/jest-runner-cypress-example %} | Example for the jest-runner-cypress diff --git a/source/faq/questions/using-cypress-faq.md b/source/faq/questions/using-cypress-faq.md index e91c8aff82..1443ad64c3 100644 --- a/source/faq/questions/using-cypress-faq.md +++ b/source/faq/questions/using-cypress-faq.md @@ -274,11 +274,11 @@ Yes, you can pass configuration to Cypress via environment variables, CLI argume ## {% fa fa-angle-right %} Can I override or change the default user agent the browser uses? -Yes. {% url "You can override this with `userAgent` in `cypress.json`." configuration#Browser %} +Yes. {% url "You can override this with `userAgent` in your configuration file (`cypress.json` by default)." configuration#Browser %} ## {% fa fa-angle-right %} Can I block traffic going to specific domains? I want to block Google Analytics or other providers. -Yes. {% url "You can set this with `blacklistHosts` in `cypress.json`." configuration#Browser %} +Yes. {% url "You can set this with `blacklistHosts` in your configuration file (`cypress.json` by default)." configuration#Browser %} Also, check out our {% url 'Stubbing Google Analytics Recipe' recipes#Stubbing-and-spying %}. @@ -336,7 +336,7 @@ It is possible to upload files in your application but it's different based on h ## {% fa fa-angle-right %} What is the projectId for? -The `projectId` is a 6 character string that helps identify your project once you've {% url "set up your tests to record" runs %}. It's generated by Cypress and typically is found in your {% url `cypress.json` configuration %} file. +The `projectId` is a 6 character string that helps identify your project once you've {% url "set up your tests to record" runs %}. It's generated by Cypress and typically is found in your {% url "configuration file (`cypress.json` by default)" configuration %} file. ```json { diff --git a/source/guides/core-concepts/writing-and-organizing-tests.md b/source/guides/core-concepts/writing-and-organizing-tests.md index dcecd42672..3e9ecf1f0b 100644 --- a/source/guides/core-concepts/writing-and-organizing-tests.md +++ b/source/guides/core-concepts/writing-and-organizing-tests.md @@ -56,14 +56,14 @@ After adding a new project, Cypress will automatically scaffold out a suggested - index.js ``` -***Configuring Folder Structure*** +## Configuring Folder Structure While Cypress allows to configure where your tests, fixtures, and support files are located, if you're starting your first project, we recommend you use the above structure. -You can modify the folder configuration in your `cypress.json`. See {% url 'configuration' configuration#Folders-Files %} for more detail. +You can modify the folder configuration in your configuration file. See {% url 'configuration' configuration#Folders-Files %} for more detail. {% note info "What files should I add to my '.gitignore file' ?" %} -Cypress will create a {% url `screenshotsFolder` configuration#Screenshots %} and a {% url `videosFolder` configuration#Videos %} to store the screenshots and videos taken during the testing of your application. Many users will opt to add these folders to their `.gitignore` file. Additionally, if you are storing sensitive environment variables in your `cypress.json` or {% url `cypress.env.json` environment-variables#Option-2-cypress-env-json %}, these should also be ignored when you check into source control. +Cypress will create a {% url `screenshotsFolder` configuration#Screenshots %} and a {% url `videosFolder` configuration#Videos %} to store the screenshots and videos taken during the testing of your application. Many users will opt to add these folders to their `.gitignore` file. Additionally, if you are storing sensitive environment variables in your configuration file (`cypress.json` by default) or {% url `cypress.env.json` environment-variables#Option-2-cypress-env-json %}, these should also be ignored when you check into source control. {% endnote %} ## Fixture Files @@ -335,14 +335,14 @@ Remember to use {% url `.only` writing-and-organizing-tests#Excluding-and-Includ ### Files -- {% url `cypress.json` configuration %} -- {% url `cypress.env.json` environment-variables %} +- {% url "Configuration file (`cypress.json`) by default" configuration %} +- {% url "`cypress.env.json`" environment-variables %} ### Folders -- `cypress/integration/` -- `cypress/support/` -- `cypress/plugins/` +- Integration directory (`cypress/integration/` by default) +- Support directory (`cypress/support/` by default) +- Plugins directory (`cypress/plugins/` by default) The folder, the files within the folder, and all child folders and their files (recursively) are watched. diff --git a/source/guides/getting-started/testing-your-app.md b/source/guides/getting-started/testing-your-app.md index 469b9527bb..38e3cd7744 100644 --- a/source/guides/getting-started/testing-your-app.md +++ b/source/guides/getting-started/testing-your-app.md @@ -96,7 +96,7 @@ If you've started your server, then you should see your application loaded and w If you think ahead, you'll quickly realize that you're going to be typing this URL a lot, since every test is going to need to visit some page of your application. Luckily, Cypress provides a {% url "configuration option" configuration %} for this. Let's leverage that now. -Open up `cypress.json`, which you will find in your project root (where you installed Cypress.) It starts out empty: +Open up your {% url "configuration file" configuration %} (`cypress.json` in your project directory, by default) It starts out empty: ```json {} @@ -113,7 +113,7 @@ Let's add the `baseUrl` option. This will automatically **prefix** {% url `cy.visit()` visit %} and {% url `cy.request()` request %} commands with this baseUrl. {% note info %} -Whenever you modify `cypress.json`, Cypress will automatically reboot itself and kill any open browsers. This is normal. Just click on the spec file again to relaunch the browser. +Whenever you modify your configuration file, Cypress will automatically reboot itself and kill any open browsers. This is normal. Just click on the spec file again to relaunch the browser. {% endnote %} We can now visit a relative path and omit the hostname and port. diff --git a/source/guides/guides/command-line.md b/source/guides/guides/command-line.md index 0ecbfa0fdc..44bd338a22 100644 --- a/source/guides/guides/command-line.md +++ b/source/guides/guides/command-line.md @@ -82,6 +82,7 @@ Option | Description `--browser`, `-b` | {% urlHash "Specify a different browser to run tests in" cypress-run-browser-lt-browser-name-or-path-gt %} `--ci-build-id` | {% urlHash "Specify a unique identifier for a run to enable grouping or parallelization." cypress-run-ci-build-id-lt-id-gt %} `--config`, `-c` | {% urlHash "Specify configuration" cypress-run-config-lt-config-gt %} +`--config-file`, `-C` | {% urlHash "Specify configuration file" cypress-run-config-file-lt-config-file-gt %} `--env`, `-e` | {% urlHash "Specify environment variables" cypress-run-env-lt-env-gt %} `--group` | {% urlHash "Group recorded tests together under a single run" cypress-run-group-lt-name-gt %} `--headed` | {% urlHash "Display the Electron browser instead of running headlessly" cypress-run-headed %} @@ -128,15 +129,29 @@ Only valid when providing a `--group` or `--parallel` flag. Read our {% url "par ### `cypress run --config ` -Read more about {% url 'environment variables' environment-variables %} and {% url 'configuration' configuration %}. +Set {% url 'configuration' configuration %} values. Separate multiple values with a comma. The values set here override any values set in your configuration file. ```shell cypress run --config pageLoadTimeout=100000,watchForFileChanges=false ``` +### `cypress run --config-file ` + +You can specify a path to a JSON file where {% url 'configuration' configuration %} values are set. This defaults to `cypress.json`. + +```shell +cypress run --config-file tests/cypress-config.json +``` + +You can pass `false` to disable the use of a configuration file entirely. + +```shell +cypress run --config-file false +``` + ### `cypress run --env ` -Pass a single string variable. +Set Cypress {% url 'environment variables' environment-variables %}. ```shell cypress run --env host=api.dev.local @@ -220,10 +235,6 @@ cypress run --port 8080 ### `cypress run --project ` -By default, Cypress expects your `cypress.json` to be found where your `package.json` is. However, you can point Cypress to run in a different location. - -This enables you to install Cypress in a top level `node_modules` folder but run Cypress in a nested folder. This is also helpful when you have multiple Cypress projects in your repo. - To see this in action we've set up an {% url 'example repo to demonstrate this here' https://github.com/cypress-io/cypress-test-nested-projects %}. ```shell @@ -298,12 +309,13 @@ cypress open [options] ### Options: -Options passed to `cypress open` will automatically be applied to the project you open. These persist on all projects until you quit the Cypress Test Runner. These options will also override values in `cypress.json`. +Options passed to `cypress open` will automatically be applied to the project you open. These persist on all projects until you quit the Cypress Test Runner. These options will also override values in your configuration file (`cypress.json` by default). Option | Description ------ | --------- `--browser`, `-b` | {% urlHash "Specify a different browser to run tests in" cypress-open-browser-lt-browser-path-gt %} `--config`, `-c` | {% urlHash "Specify configuration" cypress-open-config-lt-config-gt %} +`--config-file`, `-C` | {% urlHash "Specify configuration file" cypress-open-config-file-lt-config-file-gt %} `--detached`, `-d` | Open Cypress in detached mode `--env`, `-e` | {% urlHash "Specify environment variables" cypress-open-env-lt-env-gt %} `--global` | {% urlHash "Run in global mode" cypress-open-global %} @@ -327,16 +339,46 @@ Currently, only browsers in the Chrome family are supported. ### `cypress open --config ` +Set {% url 'configuration' configuration %} values. Separate multiple values with a comma. The values set here override any values set in your configuration file. + +```shell +cypress run --config pageLoadTimeout=100000,watchForFileChanges=false +``` + +### `cypress open --config-file ` + +You can specify a path to a JSON file where {% url 'configuration' configuration %} values are set. This defaults to `cypress.json`. + ```shell -cypress open --config pageLoadTimeout=100000,watchForFileChanges=false +cypress open --config-file tests/cypress-config.json +``` + +You can pass `false` to disable the use of a configuration file entirely. + +```shell +cypress open --config-file false ``` ### `cypress open --env ` +Set Cypress {% url 'environment variables' environment-variables %}. + ```shell cypress open --env host=api.dev.local ``` +Pass several variables using commas and no spaces. Numbers are automatically converted from strings. + +```shell +cypress open --env host=api.dev.local,port=4222 +``` + +Pass an object as a JSON in a string. + +```shell +cypress open --env flags='{"feature-a":true,"feature-b":false}' +``` + ### `cypress open --global` Opening Cypress in global mode is useful if you have multiple nested projects but want to share a single global installation of Cypress. In this case you can add each nested project to the Cypress in global mode, thus giving you a nice UI to switch between them. @@ -353,10 +395,6 @@ cypress open --port 8080 ### `cypress open --project ` -By default, Cypress expects your `cypress.json` to be found where your `package.json` is. However, you can point Cypress to run in a different location. - -This enables you to install Cypress in a top level `node_modules` folder but run Cypress in a nested folder. This is also helpful when you have multiple Cypress projects in your repo. - To see this in action we've set up an {% url 'example repo to demonstrate this here' https://github.com/cypress-io/cypress-test-nested-projects %}. ```shell diff --git a/source/guides/guides/continuous-integration.md b/source/guides/guides/continuous-integration.md index 69a3eb3cc1..e488a452d7 100644 --- a/source/guides/guides/continuous-integration.md +++ b/source/guides/guides/continuous-integration.md @@ -381,7 +381,7 @@ You can set various environment variables to modify how Cypress runs. ### Configuration Values -You can set any configuration value as an environment variable. This overrides values in your `cypress.json`. +You can set any configuration value as an environment variable. This overrides values in your configuration file (`cypress.json` by default). ***Typical use cases would be modifying things like:*** diff --git a/source/guides/guides/environment-variables.md b/source/guides/guides/environment-variables.md index 3964de47ba..62b2b8734c 100644 --- a/source/guides/guides/environment-variables.md +++ b/source/guides/guides/environment-variables.md @@ -16,7 +16,7 @@ Environment variables can be changed easily - especially when running in CI. cy.request('https://api.acme.corp') // this will break on other environments ``` -### We can move this into an environment variable. +### We can move this into a Cypress environment variable: ```javascript cy.request(Cypress.env('EXTERNAL_API')) // points to a dynamic env var @@ -29,11 +29,12 @@ However, you **do not** need to use environment variables to point to the origin {% url `cy.visit()` visit %} and {% url `cy.request()` request %} are automatically prefixed with this value - avoiding the need to specify them. -`baseUrl` can be set in your `cypress.json` - and then you can use an environment variable to override it. +`baseUrl` can be set in your configuration file (`cypress.json` by default) - and then you can use an environment variable to override it. ```shell CYPRESS_baseUrl=https://staging.app.com cypress run ``` + {% endnote %} # Setting @@ -42,7 +43,7 @@ There are 5 different ways to set environment variables. Each has a slightly dif ***To summarize you can:*** -- {% urlHash "Set in `cypress.json`" Option-1-cypress-json %} +- {% urlHash "Set in your configuration file" Option-1-configuration-file %} - {% urlHash "Create a `cypress.env.json`" Option-2-cypress-env-json %} - {% urlHash "Export as `CYPRESS_*`" Option-3-CYPRESS %} - {% urlHash "Pass in the CLI as `--env`" Option-4-env %} @@ -52,12 +53,11 @@ Don't feel obligated to pick just one method. It is common to use one strategy f When your tests are running, you can use the {% url `Cypress.env` env %} function to access the values of your environment variables. -## Option #1: `cypress.json` +## Option #1: configuration file -Any key/value you set in your {% url 'configuration' configuration %} under the `env` key will become an environment variable. +Any key/value you set in your {% url "configuration file (`cypress.json` by default)" configuration %} under the `env` key will become an environment variable. -```javascript -// cypress.json +```json { "projectId": "128076ed-9868-4e98-9cef-98dd8b705d75", "env": { @@ -87,12 +87,11 @@ Cypress.env('some') // 'value' ## Option #2: `cypress.env.json` -You can create your own `cypress.env.json` file that Cypress will automatically check. Values in here will overwrite conflicting environment variables in `cypress.json`. +You can create your own `cypress.env.json` file that Cypress will automatically check. Values in here will overwrite conflicting environment variables in your {% url "configuration file (`cypress.json` by default)" configuration %}. This strategy is useful because if you add `cypress.env.json` to your `.gitignore` file, the values in here can be different for each developer machine. -```javascript -// cypress.env.json +```json { "host": "veronica.dev.local", "api_server": "http://localhost:8888/api/v1/" @@ -124,7 +123,7 @@ Cypress.env('api_server') // 'http://localhost:8888/api/v1/' Any environment variable on your machine that starts with either `CYPRESS_` or `cypress_` will automatically be added and made available to you. -Conflicting values will override values from `cypress.json` and `cypress.env.json` files. +Conflicting values will override values from your configuration file (`cypress.json` by default) and `cypress.env.json` files. Cypress will *strip off* the `CYPRESS_` when adding your environment variables. diff --git a/source/guides/guides/module-api.md b/source/guides/guides/module-api.md index c01ad340b9..018d99d1ef 100644 --- a/source/guides/guides/module-api.md +++ b/source/guides/guides/module-api.md @@ -18,21 +18,22 @@ Just like the {% url "Command Line options" command-line %} for `cypress run`, y Option | Type | Description ------ | ---- | --------- -`browser` | *String* | Specify different browser to run tests in, either by name or by filesystem path -`ciBuildId` | *String* | Specify a unique identifier for a run to enable {% url "grouping" parallelization#Grouping-test-runs %} or {% url "parallelization" parallelization %} -`config` | *Object* | Specify {% url "configuration" configuration %} -`env` | *Object* | Specify {% url "environment variables" environment-variables %} -`group` | *String* | {% url "Group" parallelization#Grouping-test-runs %} recorded tests together under a single run -`headed` | *Boolean* | Display the Electron browser instead of running headlessly -`key` | *String* | Specify your secret record key -`exit` | *Boolean* | Whether to close Cypress after all tests run -`parallel` | *Boolean* | Run recorded specs in {% url "parallel" parallelization %} across multiple machines -`port` | *Number* | Override default port -`project` | *String* | Path to a specific project -`record` | *Boolean* | Whether to record the test run -`reporter` | *String* | Specify a {% url "Mocha reporter" reporters %} -`reporterOptions` | *Object* | Specify {% url "Mocha reporter" reporters %} options -`spec` | *String* | Specify the specs to run +`browser` | *string* | Specify different browser to run tests in, either by name or by filesystem path +`ciBuildId` | *string* | Specify a unique identifier for a run to enable {% url "grouping" parallelization#Grouping-test-runs %} or {% url "parallelization" parallelization %} +`config` | *object* | Specify {% url "configuration" configuration %} +`configFile` | *string | boolean* | Path to the config file to be used. If `false` is passed, no config file will be used. +`env` | *object* | Specify {% url "environment variables" environment-variables %} +`group` | *string* | {% url "Group" parallelization#Grouping-test-runs %} recorded tests together under a single run +`headed` | *boolean* | Display the Electron browser instead of running headlessly +`key` | *string* | Specify your secret record key +`exit` | *boolean* | Whether to close Cypress after all tests run +`parallel` | *boolean* | Run recorded specs in {% url "parallel" parallelization %} across multiple machines +`port` | *number* | Override default port +`project` | *string* | Path to a specific project +`record` | *boolean* | Whether to record the test run +`reporter` | *string* | Specify a {% url "Mocha reporter" reporters %} +`reporterOptions` | *object* | Specify {% url "Mocha reporter" reporters %} options +`spec` | *string* | Specify the specs to run ```javascript const cypress = require('cypress') @@ -118,13 +119,14 @@ Just like the {% url "Command Line options" command-line %}, you can pass option Option | Type | Description ------ | ---- | --------- -`browser` | *String* | Specify a filesystem path to a custom browser -`config` | *Options* | Specify {% url "configuration" configuration %} -`detached` | *Boolean* | Open Cypress in detached mode -`env` | *Object* | Specify {% url "environment variables" environment-variables %} -`global` | *Boolean* | Run in global mode -`port` | *Number* | Override default port -`project` | *String* | Path to a specific project +`browser` | *string* | Specify a filesystem path to a custom browser +`config` | *object* | Specify {% url "configuration" configuration %} +`configFile` | *string | boolean* | Path to the config file to be used. If `false` is passed, no config file will be used. +`detached` | *boolean* | Open Cypress in detached mode +`env` | *object* | Specify {% url "environment variables" environment-variables %} +`global` | *boolean* | Run in global mode +`port` | *number* | Override default port +`project` | *string* | Path to a specific project ### Example diff --git a/source/guides/guides/web-security.md b/source/guides/guides/web-security.md index eaf3b72698..b54abeb7f2 100644 --- a/source/guides/guides/web-security.md +++ b/source/guides/guides/web-security.md @@ -241,7 +241,7 @@ One last thing to consider here is that every once in a while we discover bugs i To start, you will need to understand that *not all browsers expose a way to turn off web security*. Some do, some don't. If you rely on disabling web security, you will not be able to run tests on browsers that do not support this feature. -**Setting `chromeWebSecurity` to `false` allows you to do the following:** +## Setting `chromeWebSecurity` to `false` allows you to do the following: - Display insecure content - Navigate to any superdomain without cross-origin errors @@ -251,7 +251,7 @@ One thing you may notice though is that Cypress still enforces visiting a single Still here? That's cool, let's disable web security! -***Set `chromeWebSecurity` to `false` in `cypress.json` and we'll take care of the rest.*** +### Set `chromeWebSecurity` to `false` in your {% url "configuration file (`cypress.json` by default)" configuration %}` and we'll take care of the rest ```json { diff --git a/source/guides/references/best-practices.md b/source/guides/references/best-practices.md index ab4f2a3def..fdf941edf8 100644 --- a/source/guides/references/best-practices.md +++ b/source/guides/references/best-practices.md @@ -578,7 +578,7 @@ We have {% url 'examples showing you how to start and stop your web server' cont {% endnote %} {% note success %} -{% fa fa-check-circle green %} **Best Practice:** Set a `baseUrl` in your `cypress.json` file. +{% fa fa-check-circle green %} **Best Practice:** Set a `baseUrl` in your {% url "configuration file (`cypress.json` by default)" configuration %}. {% endnote %} Adding a {% url "`baseUrl`" configuration#Global %} in your configuration allows you to omit passing the `baseUrl` to commands like {% url "`cy.visit()`" visit %} and {% url "`cy.request()`" request %}. Cypress assumes this is the url you want to use. @@ -595,7 +595,7 @@ As soon as it encounters a {% url "`cy.visit()`" visit %}, Cypress then switches By setting the `baseUrl`, you can avoid this reload altogether. Cypress will load the main window in the `baseUrl` you specified as soon as your tests start. -### cypress.json +### Configuration file (`cypress.json` by default) ```json { diff --git a/source/guides/references/configuration.md b/source/guides/references/configuration.md index 8432e33b70..d7fd34534d 100644 --- a/source/guides/references/configuration.md +++ b/source/guides/references/configuration.md @@ -4,11 +4,9 @@ title: Configuration When a project is added to Cypress, a `cypress.json` file is created in the project. This file is used to store the `projectId` ({% url 'after configuring your tests to record' projects#Setup %}) and any configuration values you supply. -```json -{ - "projectId": "jd90q7" -} -``` +{% note warning Change Configuration File %} +You can change the configuration file or turn off the use of a configuration file by using the {% url "`--config-file` flag" command-line#cypress-open-config-file-lt-config-file-gt %}. +{% endnote %} # Options @@ -133,7 +131,7 @@ While this may take a bit more work than other options - it yields you the most You can also use {% url 'environment variables' environment-variables %} to override configuration values. This is especially useful in {% url 'Continuous Integration' continuous-integration %} or when working locally. This gives you the ability to change configuration options without modifying any code or build scripts. -By default, any environment variable that matches a corresponding configuration key will override the `cypress.json` value. +By default, any environment variable that matches a corresponding configuration key will override the configuration file (`cypress.json` by default) value. ```shell export CYPRESS_VIEWPORT_WIDTH=800 @@ -250,4 +248,4 @@ You can turn this option off if the application or site you're testing **does no ## Intelligent Code Completion -IntelliSense is available for Cypress while editing your `cypress.json` file. {% url "Learn how to set up Intelligent Code Completion." intelligent-code-completion %} +IntelliSense is available for Cypress while editing your configuration file. {% url "Learn how to set up Intelligent Code Completion." intelligent-code-completion %} diff --git a/source/guides/references/error-messages.md b/source/guides/references/error-messages.md index 717b844ad7..42b641fefa 100644 --- a/source/guides/references/error-messages.md +++ b/source/guides/references/error-messages.md @@ -190,9 +190,9 @@ Cypress will continuously attempt to interact with the element until it eventual cy.get('#modal button').click({ waitForAnimations: false }) ``` -You can globally disable animation error checking, or increase the threshold by modifying the {% url 'configuration' configuration %} in your {% url 'configuration' configuration %}. +You can globally disable animation error checking, or increase the threshold by modifying the {% url 'configuration' configuration %}. -### cypress.json +### Configuration file (`cypress.json` by default) ```json { @@ -505,11 +505,9 @@ When your application navigates to a superdomain outside of the current origin-p 2. You are testing a page that uses Single sign-on (SSO). In this case your web server is likely redirecting you between superdomains, so you receive this error message. You can likely get around this redirect problem by using {% url `cy.request()` request %} to manually handle the session yourself. -If you find yourself stuck and can't work around these issues you can just set this in your `cypress.json` file. But before doing so you should really understand and {% url 'read about the reasoning here' web-security %}. - -```javascript -// cypress.json +If you find yourself stuck and can't work around these issues you can set this in your {% url "configuration file (`cypress.json` by default)" configuration %}. But before doing so you should really understand and {% url 'read about the reasoning here' web-security %}. +```json { "chromeWebSecurity": false } diff --git a/source/guides/tooling/intelligent-code-completion.md b/source/guides/tooling/intelligent-code-completion.md index 4e041ec0f2..96384e9b1f 100644 --- a/source/guides/tooling/intelligent-code-completion.md +++ b/source/guides/tooling/intelligent-code-completion.md @@ -88,7 +88,7 @@ Adding a {% url "`tsconfig.json`" http://www.typescriptlang.org/docs/handbook/ts ## Features: -When editing the {% url "`cypress.json`" configuration %} file, you can use our {% url "json schema file" https://on.cypress.io/cypress.schema.json %} to get intelligent tooltips in your IDE for each configuration property. +When editing the {% url "configuration file (`cypress.json` by default)" configuration %}, you can use our {% url "json schema file" https://on.cypress.io/cypress.schema.json %} to get intelligent tooltips in your IDE for each configuration property. ### Property help when writing and hovering on configuration keys @@ -102,7 +102,7 @@ When editing the {% url "`cypress.json`" configuration %} file, you can use our Intelligent code completion using JSON schemas is supported by default in {% url "Visual Studio Code" https://code.visualstudio.com/ %} and {% url "Visual Studio" https://www.visualstudio.com/ %}. All other editors will require extra configuration or plugins for JSON schema support. -To set up in {% url "Visual Studio Code" https://code.visualstudio.com/ %} you can open `Preferences / Settings / User Settings` and add the `json.schemas` property. +To set up in {% url "Visual Studio Code" https://code.visualstudio.com/ %} you can open `Preferences / Settings / User Settings` and add the `json.schemas` property. Make sure to replace `cypress.json` with your configuration file if not the default. ```json { diff --git a/source/guides/tooling/plugins-guide.md b/source/guides/tooling/plugins-guide.md index aa62fce577..bc015013dd 100644 --- a/source/guides/tooling/plugins-guide.md +++ b/source/guides/tooling/plugins-guide.md @@ -20,7 +20,7 @@ You can {% url "check out the API docs here" writing-a-plugin %}. ## Configuration -With plugins, you can programmatically alter the resolved configuration and environment variables that come from `cypress.json`, {% url `cypress.env.json` environment-variables#Option-2-cypress-env-json %}, the CLI, or system environment variables. +With plugins, you can programmatically alter the resolved configuration and environment variables that come from {% url "your configuration file (`cypress.json` by default)" configuration %}, {% url `cypress.env.json` environment-variables#Option-2-cypress-env-json %}, the {% url "command line" command-line %}, or system environment variables. This enables you to do things like: diff --git a/source/guides/tooling/reporters.md b/source/guides/tooling/reporters.md index da549fe5bf..fe44f76a35 100644 --- a/source/guides/tooling/reporters.md +++ b/source/guides/tooling/reporters.md @@ -25,9 +25,31 @@ Once you've read through the documentation below, we invite you to experience th # Reporter Options -Some reporters accept options that customize their behavior. These can be specified in your `cypress.json` or via the command line: +### Command line + +```shell +cypress run --reporter reporters/custom.js +``` + +We also support passing an absolute path to the reporter. + +## npm Reporters + +### Specify package name in configuration file (`cypress.json` by default) when installing a custom reporter through npm + +```json +{ + "reporter": "mochawesome" +} +``` + +### Command line + + + +# Reporter Options -***cypress.json*** +Some reporters accept options that customize their behavior. These can be specified in your configuration file (`cypress.json` by default) or via {% url "command line" command-line %} options: ```json { @@ -131,7 +153,7 @@ We need to install several dependencies. npm install --save-dev mocha mochawesome mochawesome-merge mochawesome-report-generator ``` -We need to configure the reporter in `cypress.json` to skip the HTML report generation and save each individual JSON file in the `cypress/results` folder. +We need to configure the reporter in your {% url "configuration file (`cypress.json` by default)" configuration %} to skip the HTML report generation and save each individual JSON file in the `cypress/results` folder. ```json {