Skip to content

Instantly share code, notes, and snippets.

@impankratov
Created December 4, 2017 13:04
Show Gist options
  • Save impankratov/ca3e160b196bbdf4f328d9577fab7236 to your computer and use it in GitHub Desktop.
Save impankratov/ca3e160b196bbdf4f328d9577fab7236 to your computer and use it in GitHub Desktop.
Test shared expect calls across the test suite with jest
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