Describe(\'The Login\', function () {\n beforeEach(function () {\n cy.readFile(Cypress.env(\'test\')).as("user")});\n\n it("Login", () => {\n cy.get("@user").then((user) =>\n cy.login(user.username, user.password))})\nRun Code Online (Sandbox Code Playgroud)\n\n失败 cypress/integration/login.spec.js\n \xe2\x97\x8f 登录页面 \xe2\x80\xba
\n\nReferenceError: cy is not defined\n\n at Object.<anonymous> (cypress/integration/login.spec.js:4:5)\n at new Promise (<anonymous>)\n at <anonymous>\n at process._tickCallback (internal/process/next_tick.js:188:7)\nRun Code Online (Sandbox Code Playgroud)\n
要为 @sai 的答案添加一些上下文,要解决此 eslint 错误,我所要做的就是从此处安装 eslint-plugin-cypress 。
npm install eslint-plugin-cypress --save-dev
Run Code Online (Sandbox Code Playgroud)
然后,在我的 eslint 配置中,我向扩展数组添加了一行。
您的配置可以是 .eslintrc.json 或 package.json 中的“eslintConfig”配置对象
npm install eslint-plugin-cypress --save-dev
Run Code Online (Sandbox Code Playgroud)