默认的 cypress 的配置文件是项目根目录下:json
cd cypress
mkdir config && cd config
touch cypress.dev.json && cypress.json
复制代码
"scripts": {
"start": "umi dev",
"cy:open:dev": "cypress open -C ./cypress/config/cypress.dev.json"
},
复制代码
{
"baseUrl": "http://192.168.0.108:8000",
"env": {
"username": "tom",
"password": "jerry"
}
}
复制代码
// env.test.spec.ts
/// <reference types="cypress" />
it("测试环境变量", () => {
cy.log(`${Cypress.env('username')}`);
cy.log(`${Cypress.env('password')}`);
})
复制代码