mirror of
https://github.com/cse110-fa22-group29/cse110-fa22-group29.git
synced 2024-12-27 09:29:10 +00:00
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>
This commit is contained in:
parent
540d6563d8
commit
dd7d876f29
@ -7,7 +7,8 @@
|
|||||||
"lint": "eslint '**/*.js'",
|
"lint": "eslint '**/*.js'",
|
||||||
"fix-style": "eslint --fix **/*.js",
|
"fix-style": "eslint --fix **/*.js",
|
||||||
"lintHTML": "htmlhint '**/*.html'",
|
"lintHTML": "htmlhint '**/*.html'",
|
||||||
"lintCSS": "stylelint '**/*.css'"
|
"lintCSS": "stylelint '**/*.css'",
|
||||||
|
"http-server": "http-server source &"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^8.27.0",
|
"eslint": "^8.27.0",
|
||||||
@ -15,6 +16,8 @@
|
|||||||
"mocha": "10",
|
"mocha": "10",
|
||||||
"mock-local-storage": "^1.1.23",
|
"mock-local-storage": "^1.1.23",
|
||||||
"stylelint": "14.14.1",
|
"stylelint": "14.14.1",
|
||||||
"stylelint-config-standard": "^29.0.0"
|
"stylelint-config-standard": "^29.0.0",
|
||||||
|
"puppeteer": "18",
|
||||||
|
"http-server": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,12 @@ import {strict as assert} from "node:assert";
|
|||||||
import {describe, it, beforeEach} from "mocha";
|
import {describe, it, beforeEach} from "mocha";
|
||||||
import {saveReviewsToStorage, getReviewsFromStorage} from "./localStorage.js";
|
import {saveReviewsToStorage, getReviewsFromStorage} from "./localStorage.js";
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
localStorage.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe("test app localStorage interaction", () => {
|
describe("test app localStorage interaction", () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
localStorage.clear();
|
||||||
|
});
|
||||||
|
|
||||||
it("get after init", () => {
|
it("get after init", () => {
|
||||||
assert.deepEqual(getReviewsFromStorage(), []);
|
assert.deepEqual(getReviewsFromStorage(), []);
|
||||||
});
|
});
|
||||||
|
31
source/assets/scripts/main.e2e.test.js
Normal file
31
source/assets/scripts/main.e2e.test.js
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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();
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user