cse110-fa22-group29/source/assets/scripts/main.e2e.test.js
Arthur Lu dd7d876f29 add dependencies to package.json,
add http-server script to package.json,
add simple e2e test in main.e2e.test.js

Signed-off-by: Arthur Lu <learthurgo@gmail.com>
2022-11-16 16:10:31 -08:00

31 lines
728 B
JavaScript

import {strict as assert} from "node:assert";
import {describe, it, beforeEach} from "mocha";
import puppeteer from 'puppeteer-core';
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{
await page.goto('http://localhost:8080', {timeout: 1000});
}
catch (error) {
console.log("❌ failed to connect to localhost webserver on port 8080")
exit(1);
}
});
it("page should have correct title", async () => {
assert.strictEqual(await page.title(), "Food Journal");
});
afterEach(async () => {
await page.close();
await browser.close();
});
});