In my react application i am trying to write e2e testing using with puppeteer (jest).
test.js
const puppeteer = require("puppeteer");
let browser;
let page;
describe("LoginPage", () => {
beforeAll(async () => {
browser = await puppeteer.launch({
headless: false,
slowMo: 250
});
page = await browser.newPage();
});
it("should display login page", async () => {
await page.goto("http://localhost:3000/");
const text = await page.evaluate(() => document.body.innerText);
expect(text).toContain("Unity");
});
it("should show error message if email is not correct", async() => {
await page.type("#email", "user");
await page.type("#password", "pass");
await page.click("button[type=submit]";
const errorMessage = await page.evaluate(
async () =>
document.getElementsByClassName("ui negative message container")[0]
);
console.log("errorMessage", errorMessage);
});
});
But this e2e testing couldn't make it work.
I am receiving an error :
Timeout - Async callback was not invoked within timeout specified by jasmine.DEFAULT_TIMEOUT_INTERVAL.
Can somebody help me to solve this issue?
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;to asetupTestFrameworkScriptFile.jsfile, which you address from jest config:setupTestFrameworkScriptFile: require.resolve('./setupTestFrameworkScriptFile.js')- Plus, you can look at chromium and see where the test is stuck. It will help you find the root cause