when learn puppeteer/jest, many tutorial articles example are the same,like:
const timeout = 10000;
beforeAll(async () => {
await page.goto(URL, { waitUntil: "domcontentloaded" });
});
describe("Test title and header of the homepage", () => {
test("Title of the page", async () => {
const title = await page.title();
expect(title).toBe("Learn Web Development with free Classes and Tutorials - Sabe.io");
}, timeout);
test("Header of the page", async () => {
const h1Handle = await page.$("h1");
const html = await page.evaluate(h1Handle => h1Handle.innerHTML, h1Handle);
expect(html).toBe("Become a better developer");
}, timeout);
});
and the jest.config.js like:
module.exports = {
preset: "jest-puppeteer",
globals: {
URL: "https://sabe.io"
},
testMatch: [
"**/test/**/*.test.js"
],
verbose: true
}
and they all success in article, but when i run that code on local, get an error :
ProtocolError: Protocol error (Page.navigate): Invalid parameters Failed to deserialize params.url - BINDINGS: mandatory field missing at position 49
or
ReferenceError: URL is not defined
does anybody get the same error ?