Commit 924e8313 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

test: keep test output clean (#6469)

parent 4d5cc826
......@@ -3,6 +3,7 @@ import 'jest-styled-components' // adds style diffs to snapshot tests
import type { createPopper } from '@popperjs/core'
import { useWeb3React } from '@web3-react/core'
import failOnConsole from 'jest-fail-on-console'
import ResizeObserver from 'resize-observer-polyfill'
import { Readable } from 'stream'
import { mocked } from 'test-utils/mocked'
......@@ -77,3 +78,22 @@ beforeEach(() => {
// Mock useWeb3React to return a chainId of 1 by default.
mocked(useWeb3React).mockReturnValue({ chainId: 1 } as ReturnType<typeof useWeb3React>)
})
/**
* Fail tests if anything is logged to the console. This keeps the console clean and ensures test output stays readable.
* If something should log to the console, it should be stubbed and asserted:
* @example
* beforeEach(() => jest.spyOn(console, 'error').mockReturnsValue())
* it('should log an error', () => {
* example()
* expect(console.error).toHaveBeenCalledWith(expect.any(Error))
* })
*/
failOnConsole({
shouldFailOnAssert: true,
shouldFailOnDebug: true,
shouldFailOnError: true,
shouldFailOnInfo: true,
shouldFailOnLog: true,
shouldFailOnWarn: true,
})
......@@ -13396,6 +13396,13 @@ jest-environment-node@^26.6.2:
jest-mock "^26.6.2"
jest-util "^26.6.2"
jest-fail-on-console@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/jest-fail-on-console/-/jest-fail-on-console-3.1.1.tgz#4ca0d0cc8f11675e8e9f52159a37a6602a7e6c09"
integrity sha512-g9HGhKcWOz8lHeZhLCXGg+RD/7upngiKkkBrHimsO/tGB0qi++QZffOgybjeI2bDW1qgdFiJJEG6t/WeTlfmOw==
dependencies:
chalk "^4.1.0"
jest-fetch-mock@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/jest-fetch-mock/-/jest-fetch-mock-3.0.3.tgz#31749c456ae27b8919d69824f1c2bd85fe0a1f3b"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment