Last active
July 3, 2020 14:29
-
-
Save marcoemrich/79ca4e65d7e80697af3a18b05224acd4 to your computer and use it in GitHub Desktop.
JS-Testing: Assertion Examples
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('greater than in obj', () => { | |
// is the second value of the obj greater than 5? | |
const obj = {value: [5, 4]}; | |
// different Assertions/Expectations/Matcher Variants | |
it('jest equal', () => expect(obj.value[1] > 5).toBeTruthy()); | |
it('jest greater', () => expect(obj.value[1]).toBeGreaterThan(5)); | |
it('jest matchObject', () => expect(obj).toMatchObject({value: [5, 5]})); | |
it('unexpected satisfy', () => | |
unexpect(obj, 'to satisfy', {value: [5, unexpect.it('to be greater than', 4)]}) | |
); | |
it('power assert', () => assert(obj.value[1] > 5)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment