Skip to content

Instantly share code, notes, and snippets.

@hhyyg
Created Aug 8, 2021
Embed
What would you like to do?
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