Created
July 31, 2018 06:01
-
-
Save andreiashu/aff9308c89f132a210bcea8893bb2e30 to your computer and use it in GitHub Desktop.
Jest tests that helped me understand how different Jest settings behave
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
describe("Understand Jest framework", () => { | |
test("async works with Promise.resolve", async () => Promise.resolve(true)) | |
test("async works with return", async () => true) | |
test("async works with expect met", async () => expect(true).toBe(true)) | |
test("expect throws", async () => { | |
try { | |
expect(true).toBe(false) | |
console.log('This should not be printed') | |
} catch (err) { | |
// silence the error | |
} | |
}) | |
test("async with resolving promise", async () => { | |
const result = await new Promise((resolve) => { | |
setTimeout(() => { | |
resolve(1) | |
}, 1) | |
}) | |
expect(result).toBe(1) | |
}) | |
test("this test should fail", async () => { | |
expect(true).toBe(false) | |
}) | |
test("test not reached if using --bail and --inband. right?!", async () => { | |
expect("Should not be evaluated").toBe("Jest bug?") | |
}) | |
}) | |
describe("Understand Jest --bail + --inband param", () => { | |
test('How does --bail work?', async () => { | |
expect(1).toBe(1) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With Jest 23.4.1 I get: