Specifies the startup name open

The default cypress configuration file is in the project root directory:

Customizing Cypress’s environment profile:

cd cypress
mkdir config && cd config
touch cypress.dev.json && cypress.json
Copy the code

Package. json script starts

"scripts": {
    "start": "umi dev"."cy:open:dev": "cypress open -C ./cypress/config/cypress.dev.json"
},
Copy the code

Configure the development environment variables in cypress.dev.json

{
"baseUrl": "http://192.168.0.108:8000"."env": {
    "username": "tom"."password": "jerry"}}Copy the code

Access environment variables from test cases

// env.test.spec.ts
/// <reference types="cypress" />

it("Test environment variables".() = > {
    cy.log(`${Cypress.env('username')}`);
    cy.log(`${Cypress.env('password')}`);
})
Copy the code