Courses / Frontend Testing
2. basic test case (test/it + expect)
Using test or it with expect to write a simple unit assertion in Jest.
JavaScript
basic test case (test/it + expect)
A simple unit test uses test/it with expect to assert a function returns the value you expect.
"I want to check one small piece of code behaves the way I think, automatically."
A basic Jest test wraps a single assertion in test() or it(), calling expect(actual).matcher(expected) to verify behavior; the test passes when the assertion is true and fails otherwise.
"I want to check one small piece of code behaves the way I think, automatically."
A basic Jest test wraps a single assertion in test() or it(), calling expect(actual).matcher(expected) to verify behavior; the test passes when the assertion is true and fails otherwise.