Public
Edited
Nov 10
1 fork
Importers
19 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
suite.test("sync pass", () => expect(true).toBe(true))
Insert cell
Insert cell
suite.test("sync fail", () => expect(true).toBe(false))
Insert cell
suite.test("throw exception", () => {
console.log("Run: Throws exception")
expect(() => {
throw new Error("Expected exception");
}).toThrow();
})
Insert cell
suite.test("asyncORIG - original function", async () => {
console.log("Run: async function")
await new Promise(resolve => setTimeout(resolve, 500));
return "foo2"
})
Insert cell
Insert cell
Insert cell
suite.test("async0 - should fail, no resolve", async () => {
console.log("Run: async function")
// await new Promise(resolve => setTimeout(resolve, 1000));
await new Promise( resolve => {});
})
Insert cell
suite.test("async1 check returned data", async () => {
await new Promise(resolve => setTimeout(()=>resolve("foo"), 1000))
.then(data => {
expect(data).toBe("foo");
})
})
Insert cell
Insert cell
suite.test("async2 function hanging example, should fail", done => {
});

// based on "unresolved" example at https://jestjs.io/docs/en/asynchronous

Insert cell
Insert cell
suite.test("done arg is an error", done => {
done(new Error("Not an error really"));
})

// based on "unresolved" example at https://jestjs.io/docs/en/asynchronous
Insert cell
Insert cell
Insert cell
suite.test("async4: the data is peanut butter", () => {
const fetchData = () => new Promise((resolve) => resolve("peanut butter"));
return fetchData().then((data) => {
expect(data).toBe("peanut butter");
});
})

// adapted example from https://jestjs.io/docs/en/asynchronous
// not using await
Insert cell
Insert cell
suite.viewofResults.value
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
//import { customJsonFormatter } from "@tomlarkworthy/highlight"
Insert cell
//import { footer } from "@tomlarkworthy/footer"
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more