Created
December 4, 2017 13:04
-
-
Save impankratov/ca3e160b196bbdf4f328d9577fab7236 to your computer and use it in GitHub Desktop.
Test shared expect calls across the test suite with jest
This file contains hidden or 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
const testGroupOfExpects = target => { | |
expect(!!target).toBe(true); | |
expect(target).toContain(1); | |
}; | |
describe('grouping', () => { | |
it('should do smth', () => { | |
const target = [1, 2]; | |
testGroupOfExpects(target); | |
}); | |
it('should do the same plus', () => { | |
const target = [1, 2, { some: 'prop' }]; | |
testGroupOfExpects(target); | |
expect(target[2]).toMatchObject({ some: 'prop' }); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment