Last active
February 26, 2020 08:36
-
-
Save kamiazya/17ea59b0461c6e69e12b63a05f2b0331 to your computer and use it in GitHub Desktop.
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
// config/jest/add-custom-matchers.ts | |
import toBeValidDot from '../../test/unit/customMatchers/toBeValidDot'; | |
expect.extend(toBeValidDot); |
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
// test/unit/customMatchers.d.ts | |
declare namespace jest { | |
interface Matchers<R, T> { | |
toBeValidDot(): R; | |
} | |
interface Expect { | |
toBeValidDot: () => any; | |
} | |
interface InverseAsymmetricMatchers { | |
toBeValidDot: () => any; | |
} | |
} |
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
module.exports = { | |
preset: 'ts-jest', | |
testEnvironment: 'node', | |
verbose: true, | |
collectCoverage: true, | |
setupFilesAfterEnv: [ | |
'<rootDir>/config/jest/add-custom-matchers.ts', | |
], | |
}; |
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
// test/unit/customMatchers/toBeValidDot.ts | |
async function toBeValidDot(this: any, dot: string): Promise<jest.CustomMatcherResult> { | |
return { | |
pass: true, | |
message: () => '', | |
}; | |
} | |
export default { toBeValidDot }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment