Skip to content

Instantly share code, notes, and snippets.

@aaditkamat
Last active September 18, 2022 08:00
Show Gist options
  • Save aaditkamat/0b580a4ebcc9a7abca2badb788d6d5dc to your computer and use it in GitHub Desktop.
Save aaditkamat/0b580a4ebcc9a7abca2badb788d6d5dc to your computer and use it in GitHub Desktop.
Unit testing with Jest and React Testing Library
beforeAll(() => {
console.log("This statement will get executed before all the test cases");
});
afterAll(() => {
console.log("This statement will get executed after all the test cases");
});
describe("test suite", () => {
beforeEach(() => {
console.log("This statement will get executed before each test case");
});
afterEach(() => {
console.log("This statement will get executed after each test case");
});
it("first test", () => {
expect(1).toBe(1);
});
// alternative to it
test("second test", () => {
expect(1).not.toBe(2);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment