-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: notify maintainers of releases and issues
- Loading branch information
Showing
24 changed files
with
907 additions
and
167 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
declare global { | ||
namespace jest { | ||
interface Matchers<R> { | ||
toThrowErrorContaining<T extends Error>( | ||
errorType: new (...args: any[]) => T, | ||
message: string | ||
): R; | ||
} | ||
} | ||
} | ||
|
||
expect.extend({ | ||
toThrowErrorContaining<T extends Error>( | ||
func: Function, | ||
errorType: new (...args: any[]) => T, | ||
message: string | ||
) { | ||
try { | ||
func(); | ||
} catch (e) { | ||
if (!(e instanceof errorType)) { | ||
return { | ||
pass: false, | ||
message: () => `\ | ||
Expected error to throw: | ||
${errorType} | ||
But instead it threw: | ||
${e.constructor} | ||
`, | ||
}; | ||
} | ||
|
||
if (!e.message.includes(message)) { | ||
return { | ||
pass: false, | ||
message: () => `\ | ||
Expected error message to contain: | ||
${message} | ||
But instead it was: | ||
${e.message} | ||
`, | ||
}; | ||
} | ||
|
||
return { | ||
pass: true, | ||
message: () => "", | ||
}; | ||
} | ||
|
||
return { | ||
pass: false, | ||
message: () => "Expected function to throw but it did not", | ||
}; | ||
}, | ||
}); | ||
|
||
export default undefined; |
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
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
Oops, something went wrong.