test: Add revive test with puppeteer (#185)

This commit is contained in:
Sylvain Cau
2022-05-14 12:28:41 +02:00
committed by GitHub
parent ec388f87fb
commit 2f053816f4
4 changed files with 35 additions and 2 deletions
+8
View File
@@ -35,6 +35,14 @@ jobs:
- name: Cache dependencies
run: deno cache --no-check src/cli/deps.ts src/runtime/deps.ts src/server/deps.ts
- name: Setup puppeteer linux / mac
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'mac')
run: PUPPETEER_PRODUCT=chrome deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
- name: Setup puppeteer windows
if: startsWith(matrix.os, 'windows')
run: set "PUPPETEER_PRODUCT=chrome" && deno run -A --unstable https://deno.land/x/puppeteer@9.0.2/install.ts
- name: Run tests
run: deno test -A --no-check=remote
+25 -1
View File
@@ -1,4 +1,10 @@
import { assert, assertEquals, delay, TextLineStream } from "./deps.ts";
import {
assert,
assertEquals,
delay,
puppeteer,
TextLineStream,
} from "./deps.ts";
type FileTree = {
type: "file";
@@ -120,6 +126,24 @@ Deno.test({
await res.body?.cancel();
assertEquals(res.status, 200);
// verify the island is revived.
const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto("http://localhost:8000");
await delay(500);
const counter = await page.$("body > div > div > p");
let counterValue = await counter?.evaluate((el) => el.textContent);
assert(counterValue === "3");
const buttonPlus = await page.$("body > div > div > button:nth-child(3)");
await buttonPlus?.click();
counterValue = await counter?.evaluate((el) => el.textContent);
assert(counterValue === "4");
await browser.close();
await lines.cancel();
serverProcess.kill("SIGTERM");
serverProcess.close();
+1
View File
@@ -7,3 +7,4 @@ export {
TextLineStream,
} from "https://deno.land/std@0.129.0/streams/delimiter.ts";
export { delay } from "https://deno.land/std@0.129.0/async/delay.ts";
export { default as puppeteer } from "https://deno.land/x/puppeteer@9.0.2/mod.ts";
+1 -1
View File
@@ -290,7 +290,7 @@ Deno.test({
});
Deno.test({
name: "/middleware - layer 3 middleware ",
name: "/middleware - layer 3 middleware",
fn: async () => {
// layered 3 should contain layer 3 middleware data
const resp = await router(