Last active
January 4, 2023 18:10
-
-
Save Maurifc/e01dc0b9207eac694ec98c395498aa3c to your computer and use it in GitHub Desktop.
nodejs - Boiler plate of a test.js file (jest)
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
/* eslint-disable no-undef */ | |
import { jest } from '@jest/globals' | |
// run before all tests (setup) | |
beforeAll(async () => { | |
// setup the test environment | |
// mock | |
}) | |
// run before each test | |
beforeEach(async () => { | |
jest.clearAllMocks() | |
}) | |
describe('utils/sum.js', () => { | |
describe('sum function', () => { | |
test('Should return the sum of two numbers', async () => { | |
const sum = (num1, num2) => { return num1 + num2 } | |
expect(sum(2, 3)).toBe(5) | |
}) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment