下面的e2e测试引发以下错误:
Timeout - Async callback was not invoked within timeout specified byjasmine.DEFAULT_TIMEOUT_INTERVAL.
// describe the test
describe('Login Component Tests',
() => {
const handleSubmit = jest.fn();
let browser;
let page;
beforeAll(async () => {
browser = await puppeteer.launch({
headless: false,
});
page = await browser.newPage();
}); // timeout
afterAll(() => {
browser = browser.close();
});
// handler submits
it('has a handler that submits', async (done) => {
await page.goto('http://localhost:3000/login');
page.emulate({
viewport: {
width: 1000,
height: 800,
},
userAgent: '',
});
await page.waitForSelector('.login-form');
await page.type('input[name=email]', 'username');
await page.type('input[name=password]', 'password');
await page.click('button[type=submit]');
const error = await page.waitForSelector('.ant-message-notice');
expect(error).not.toBe('object');
});
},
10000,
);
无头chrome会加载登录页面并使用凭据登录,但错误仍然出现。
我尝试在describe
块中设置间隔,但仍然失败。开玩笑不知道这里有什么问题。