toBe() or not.toBe()
2022年5月1日小于 1 分钟
toBe() or not.toBe()
Question
Here are some simple Jest test code.
expect(3).toBe(3) // ✅
expect(4).toBe(3) // ❌
We can reverse it with not
.
expect(3).not.toBe(3) // ❌
expect(4).not.toBe(3) // ✅
Please implement myExpect()
to support toBe()
and also not
.
Code
/**
* interface Matcher {
* toBe(data: any): void
* }
*/
/**
* @param {any} input
* @returns {Matcher & {not: Matcher}}
*/
function myExpect(input) {
// your code here
}