2022-11-17 00:10:31 +00:00
|
|
|
import {strict as assert} from "node:assert";
|
2022-11-17 00:46:02 +00:00
|
|
|
import {describe, it, beforeEach, afterEach} from "mocha";
|
|
|
|
import puppeteer from "puppeteer-core";
|
2022-11-17 00:10:31 +00:00
|
|
|
import { exit } from "node:process";
|
|
|
|
|
|
|
|
describe("test App end to end", async () => {
|
|
|
|
|
|
|
|
let browser;
|
|
|
|
let page;
|
|
|
|
|
|
|
|
beforeEach(async () => {
|
|
|
|
browser = await puppeteer.launch();
|
|
|
|
page = await browser.newPage();
|
|
|
|
try{
|
2022-11-17 00:46:02 +00:00
|
|
|
await page.goto("http://localhost:8080", {timeout: 1000});
|
2022-11-17 00:10:31 +00:00
|
|
|
}
|
|
|
|
catch (error) {
|
2022-11-17 00:46:02 +00:00
|
|
|
console.log("❌ failed to connect to localhost webserver on port 8080");
|
2022-11-17 00:10:31 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
it("page should have correct title", async () => {
|
|
|
|
assert.strictEqual(await page.title(), "Food Journal");
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(async () => {
|
|
|
|
await page.close();
|
|
|
|
await browser.close();
|
|
|
|
});
|
|
|
|
});
|