Timeout-Async callback was not invoked within the 5000ms timeout specified
recently working on UI tests, using jest and puppeteer. Mainly to test the login page.
I have been messing around with the online tutorials for a long time, and there is a mistake that I don"t know how to solve.
errors are as follows:
Timeout - Async callback was not invoked within the 5000ms timeout specified by jest.setTimeout.
63 | });
64 |
> 65 | test("login failure", async () => {
| ^
66 | await page.waitForSelector("-sharpusername", {
67 | timeout: 5000,
68 | });
at Spec (node_modules/jest-jasmine2/build/jasmine/Spec.js:85:20)
at Object.test (src/tests/login.test.js:65:1)
the code for the test is as follows:
const puppeteer = require("puppeteer");
let browser;
let page;
beforeAll(async () => {
browser = await puppeteer.launch({
headless: false,
slowMo: 200,
});
page = await browser.newPage();
});
afterAll(() => {
browser.close();
});
test("open page", async () => {
await page.goto("localhost:8000/web/login");
});
test("login failure", async () => {
await page.waitForSelector("-sharpusername", {
timeout: 5000,
});
await page.type("-sharpusername", "test");
await page.type("-sharppassword", "1111");
await page.click("-sharpsubmit");
await page.waitForSelector(".ant-message-notice",{ timeout: 5000});
});
up to now, I have done a good job in the agreement
. For protocol errors, I changed page.goto ("http://localhost:8000/web/login")
to page.goto) (" localhost:8000/web/login"
for Ok) ~
PASS src/tests/login.test.js (9.914s)
open page (2080ms)
login failure (4981ms)
Test Suites: 1 passed, 1 total
Tests: 2 passed, 2 total
Snapshots: 0 total
Time: 10.871s
Ran all test suites.