我有一个测试,其中我的beforeEach
方法中有几个前提条件
但是,当我运行测试时,仅满足其中一个条件(创建客户端),而另一个则被忽略。
那是为什么?
import puppeteer from "puppeteer";
const CheckMethods = require('../../../methods/common/checks');
const CreateMethods = require('../../../methods/common/create');
const config = require('../../../../../config/config');
let page;
let browser;
let clientExists;
let portalExists;
describe('Super - User', () => {
const checks = new CheckMethods();
const create = new CreateMethods();
beforeEach(async () => {
browser = await puppeteer.launch(config.puppeteer);
page = await browser.newPage();
await page.setViewport(config.browser);
await page.goto(`${config.ui_endpoint}/super/#login`, {
waitUntil: 'networkidle2'
})
clientExists = await checks.superClientExists(page)
console.log('clientExists :', clientExists); // CALLED
if (!clientExists) {
await create.createSuperClient(page)
}
await page.waitFor(1000)
portalExists = await checks.superPortalExists(page)
console.log('portalExists :', portalExists); // NOT CALLED
if (!portalExists) {
await create.createSuperPortal(page);
}
});
afterEach(async () => {
await browser.close();
});
it.only('should be able to make client in super a sales rep and assing portal', async () => {
..
}, 150000)
});
答案 0 :(得分:0)
您是否尝试过向beforeEach
调用添加更高的(与标准的相比)超时?像beforeEach(async () => {}, 100000)
。