我正在尝试在我的 cypress 框架上设置一种方法,以便在每个测试场景中执行一些操作,其中包括 cy.request。
我的beforeEach.js
文件位于以下位置:
import { Actor, Action } from "cypress-screenplay";
import * as auth from "../../../../../support/ui/auth";
new Actor().perform(auth.uiLogin);
(Actor 对象最终执行 cy.request)以通过 API 执行登录)。
然后通过最简单的测试,我收到以下消息:
The following error originated from your test code, not from Cypress.
> Cannot call cy.request() outside a running test.
This usually happens when you accidentally write commands outside an it(...) test.
If that is the case, just move these commands inside an it(...) test.
我还能如何解决这个问题?
我不想在我的黄瓜测试的另一个步骤中包含 beforeEach 的内容,因为它会增加很多噪音(每次测试一行,在 100 次测试中......)