smartexpect/test/test.negation.ts

22 lines
706 B
TypeScript

import { tap, expect as tExpect } from '@push.rocks/tapbundle';
import * as smartexpect from '../dist_ts/index.js';
tap.test('negation message for numeric matcher', async () => {
try {
smartexpect.expect(5).not.toBeGreaterThan(3);
throw new Error('Assertion did not throw');
} catch (err: any) {
tExpect(err.message).toEqual('Expected number not to be greater than 3');
}
});
tap.test('negation message for string matcher', async () => {
try {
smartexpect.expect('hello').not.string.toInclude('he');
throw new Error('Assertion did not throw');
} catch (err: any) {
tExpect(err.message).toEqual('Expected string not to include "he"');
}
});
export default tap.start();