-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added fetch support to JSDOMRunner (#27)
- Loading branch information
1 parent
c5f4e43
commit 0129ff4
Showing
4 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"foo": "bar", | ||
"baz": 123 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<m-plane color="pink" width="20" height="20" rx="-90"></m-plane> | ||
<m-light type="spotlight" ry="45" rx="65" rz="-45" x="10" y="10" z="10"></m-light> | ||
|
||
<m-label id="json-content" content="loading" y="4.5" font-size="50" width="10" alignment="center" height="1" color="#dddddd"></m-label> | ||
|
||
<script> | ||
const contentLabel = document.getElementById("json-content"); | ||
async function fetchData() { | ||
const address = `http://localhost:8079/assets/some-data.json`; | ||
const res = await fetch(address); | ||
const json = await res.json(); | ||
contentLabel.setAttribute("content", `${JSON.stringify(json)}`); | ||
} | ||
fetchData(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { takeAndCompareScreenshot } from "./testing-utils"; | ||
|
||
describe("fetch", () => { | ||
test("fetch-ed content", async () => { | ||
const page = await globalThis.__BROWSER_GLOBAL__.newPage(); | ||
|
||
await page.setViewport({ width: 1024, height: 1024 }); | ||
|
||
await page.goto("http://localhost:8079/fetch-test.html/reset"); | ||
|
||
const textSelector = await page.waitForSelector("m-label"); | ||
const fullTitle = await textSelector?.evaluate((el) => el.getAttribute("content")); | ||
expect(fullTitle).toEqual(`{"foo":"bar","baz":123}`); | ||
|
||
await page.close(); | ||
}, 60000); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters