Skip to content

Instantly share code, notes, and snippets.

@hhyyg
Created August 8, 2021 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hhyyg/c4c6b5f384ece4d5c008fc292d0c461b to your computer and use it in GitHub Desktop.
Save hhyyg/c4c6b5f384ece4d5c008fc292d0c461b to your computer and use it in GitHub Desktop.
Jasmine tests
const somethingPromise = (ms) =>
new Promise((resolve) => setTimeout(resolve, ms));
const somethingErrorPromise = (ms) =>
new Promise((resolve) => {
throw new Error();
});
describe("test", () => {
it("test", async (done) => {
await somethingPromise(1000);
done();
});
it("test2", (done) => {
(async () => {
await somethingPromise(1000);
await somethingPromise(1000);
//done();
})();
});
it("test3", async () => {
await somethingPromise(1000);
await somethingPromise(1000);
await expectAsync(somethingPromise(1000)).toBeRejectedWithError();
await expectAsync(somethingErrorPromise(1000)).toBeRejected();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment