test: fix & improve ssr warning assertion

This commit is contained in:
Evan You
2020-03-10 17:13:27 -04:00
parent 80c625dce3
commit 7af089d429
3 changed files with 14 additions and 23 deletions

View File

@@ -8,7 +8,9 @@ declare global {
}
}
export function mockWarn() {
export const mockError = () => mockWarn(true)
export function mockWarn(asError = false) {
expect.extend({
toHaveBeenWarned(received: string) {
asserted.add(received)
@@ -79,7 +81,7 @@ export function mockWarn() {
beforeEach(() => {
asserted.clear()
warn = jest.spyOn(console, 'warn')
warn = jest.spyOn(console, asError ? 'error' : 'warn')
warn.mockImplementation(() => {})
})