Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
skip apollo test if Node 12
  • Loading branch information
brillout committed Sep 18, 2021
1 parent 7fd9c89 commit 823f7ed
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion examples/base-url/.testPages.ts
Expand Up @@ -15,7 +15,7 @@ function testPages(
const baseUrl = isDev ? "" : "/dist/client";
const addBaseUrl = (url: string) => baseUrl + url;

run(cmd, baseUrl);
run(cmd, { baseUrl });

test("page content is rendered to HTML", async () => {
const html = await fetchHtml(addBaseUrl("/"));
Expand Down
43 changes: 26 additions & 17 deletions examples/graphql-apollo/.test.spec.ts
Expand Up @@ -4,25 +4,34 @@ import {
page,
run,
urlBase,
isMinNodeVersion,
} from "../../libframe/test/setup";

run("npm run start");
runTest();

test("page is rendered to HTML", async () => {
const html = await fetchHtml("/");
expect(html).toContain(
"<li>Angola</li><li>Antarctica</li><li>Argentina</li><li>American Samoa</li>"
);
expect(html).toContain("<button>Counter <span>0</span></button>");
});
function runTest() {
if (!isMinNodeVersion(14)) {
return;
}

test("page is hydrated to DOM", async () => {
page.goto(`${urlBase}/`);
expect(await page.textContent("button")).toBe("Counter 0");
// `autoRetry` because browser-side code may not be loaded yet
await autoRetry(async () => {
await page.click("button");
expect(await page.textContent("button")).toBe("Counter 1");
run("npm run start");

test("page is rendered to HTML", async () => {
const html = await fetchHtml("/");
expect(html).toContain(
"<li>Angola</li><li>Antarctica</li><li>Argentina</li><li>American Samoa</li>"
);
expect(html).toContain("<button>Counter <span>0</span></button>");
});

test("page is hydrated to DOM", async () => {
page.goto(`${urlBase}/`);
expect(await page.textContent("button")).toBe("Counter 0");
// `autoRetry` because browser-side code may not be loaded yet
await autoRetry(async () => {
await page.click("button");
expect(await page.textContent("button")).toBe("Counter 1");
});
expect(await page.textContent("body")).toContain("Antarctica");
});
expect(await page.textContent("body")).toContain("Antarctica");
});
}
5 changes: 5 additions & 0 deletions examples/react-full/.testPages.ts
Expand Up @@ -4,6 +4,7 @@ import {
urlBase,
fetchHtml,
autoRetry,
isMinNodeVersion,
} from "../../libframe/test/setup";
import assert = require("assert");

Expand All @@ -13,6 +14,10 @@ function testPages(
viewFramework: "vue" | "react",
cmd: "npm run start" | "npm run prod"
) {
if (!isMinNodeVersion(14)) {
return;
}

run(cmd);

test("page content is rendered to HTML", async () => {
Expand Down
2 changes: 1 addition & 1 deletion libframe

0 comments on commit 823f7ed

Please sign in to comment.