From bd04abd31cc1d0e1b069f309c9f88db9fcfe0252 Mon Sep 17 00:00:00 2001 From: Arya Emami Date: Fri, 2 Aug 2024 02:06:16 -0500 Subject: [PATCH] Remove `console-testing-library` as it is no longer needed --- ...testing-library-npm-0.6.1-4d9957d402.patch | 68 ------------------- .../console-testing-library__npm_0.3.1.patch | 26 ------- packages/toolkit/package.json | 1 - .../src/tests/utils/CustomMatchers.d.ts | 1 - packages/toolkit/src/tests/utils/helpers.tsx | 53 --------------- yarn.lock | 23 ------- 6 files changed, 172 deletions(-) delete mode 100644 .yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch delete mode 100644 .yarn/patches/console-testing-library__npm_0.3.1.patch diff --git a/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch b/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch deleted file mode 100644 index 7f41eabd06..0000000000 --- a/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch +++ /dev/null @@ -1,68 +0,0 @@ -diff --git a/package.json b/package.json -index b924e066ecfdb30917b9c1056b360834da357698..15e155bd84f9d16537ffe36f9a87debcb0ec3591 100644 ---- a/package.json -+++ b/package.json -@@ -8,12 +8,15 @@ - "type": "module", - "main": "dist/index.js", - "typings": "index.d.ts", -+ "types": "index.d.ts", - "exports": { - ".": { -+ "types": "./index.d.ts", - "require": "./dist/index.js", - "default": "./src/index.js" - }, - "./pure": { -+ "types": "./pure.d.ts", - "require": "./dist/pure.js", - "default": "./src/pure.js" - } -diff --git a/pure.d.ts b/pure.d.ts -index b13bb4eb87d0b316bb51bd6094b2353c6fc8527d..ee01cc9bd3233f5e67b050d48e22202b495a4a0a 100644 ---- a/pure.d.ts -+++ b/pure.d.ts -@@ -1 +1 @@ --export * from './'; -+export * from './index.js'; -diff --git a/src/index.js b/src/index.js -index 90ff7fa3d7d4fa62dbbf638958ae4e28abd089a8..28434687b5163b7472e86bdb11bed69e0868e660 100644 ---- a/src/index.js -+++ b/src/index.js -@@ -1,4 +1,4 @@ --import { mockConsole, createConsole } from './pure'; -+import { mockConsole, createConsole } from './pure.js'; - - // Keep an instance of the original console and export it - const originalConsole = global.console; -diff --git a/src/pure.js b/src/pure.js -index b00ea2abbaea833e336676aa46e7ced2d59d6d88..42b83ed83fa16cf2234571500fe09868debd9f01 100644 ---- a/src/pure.js -+++ b/src/pure.js -@@ -228,10 +228,11 @@ export function restore() { - global.console = global.originalConsole; - } - -+/* - if (typeof expect === 'function' && typeof expect.extend === 'function') { - expect.extend({ - toMatchInlineSnapshot(received, ...args) { -- /* ------- Workaround for custom inline snapshot matchers ------- */ -+ // Workaround for custom inline snapshot matchers - const error = new Error(); - const stacks = error.stack.split('\n'); - -@@ -245,7 +246,6 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') { - error.stack = stacks.join('\n'); - - const context = Object.assign(this, { error }); -- /* -------------------------------------------------------------- */ - - const testingConsoleInstance = - (received && received.testingConsole) || received; -@@ -270,3 +270,4 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') { - }, - }); - } -+*/ -\ No newline at end of file diff --git a/.yarn/patches/console-testing-library__npm_0.3.1.patch b/.yarn/patches/console-testing-library__npm_0.3.1.patch deleted file mode 100644 index b0db4c6ca2..0000000000 --- a/.yarn/patches/console-testing-library__npm_0.3.1.patch +++ /dev/null @@ -1,26 +0,0 @@ -diff --git a/index.d.ts b/index.d.ts -index 1dbf70a6fdf4369188ad44166aee188c8efd2054..56b85e26b2b3030bc3407aab2b358fd4e5e39c6a 100644 ---- a/index.d.ts -+++ b/index.d.ts -@@ -1,4 +1,4 @@ --export const originalConsole = Console; -+export declare const originalConsole: Console; - - type Options = { - isSilent?: boolean; -@@ -24,14 +24,13 @@ export type TestingConsoleInstance = { - }; - getRecord: (method: string) => string; - silence: boolean; -- private _targetConsole: TestingConsole | Console; - }; - - export function createConsole(options?: Options): TestingConsole; - - export function mockConsole( - testingConsole: TestingConsole, -- targetConsoleParent?: {} = global, -+ targetConsoleParent?: typeof globalThis, - targetConsoleKey?: string - ): () => void; - diff --git a/packages/toolkit/package.json b/packages/toolkit/package.json index 2b765b1e6a..8a9a86beba 100644 --- a/packages/toolkit/package.json +++ b/packages/toolkit/package.json @@ -70,7 +70,6 @@ "@typescript-eslint/eslint-plugin": "^6", "@typescript-eslint/parser": "^6", "axios": "^0.19.2", - "console-testing-library": "patch:console-testing-library@npm%3A0.6.1#~/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch", "esbuild": "^0.23.0", "esbuild-extra": "^0.4.0", "eslint": "^7.25.0", diff --git a/packages/toolkit/src/tests/utils/CustomMatchers.d.ts b/packages/toolkit/src/tests/utils/CustomMatchers.d.ts index 955e51db36..9eba34f5c1 100644 --- a/packages/toolkit/src/tests/utils/CustomMatchers.d.ts +++ b/packages/toolkit/src/tests/utils/CustomMatchers.d.ts @@ -1,7 +1,6 @@ import type { Assertion, AsymmetricMatchersContaining } from 'vitest' interface CustomMatchers { - toHaveConsoleOutput(expectedOutput: string): Promise toMatchSequence(...matchers: Array<(arg: any) => boolean>): R } diff --git a/packages/toolkit/src/tests/utils/helpers.tsx b/packages/toolkit/src/tests/utils/helpers.tsx index 5ccedc434d..402fdda91f 100644 --- a/packages/toolkit/src/tests/utils/helpers.tsx +++ b/packages/toolkit/src/tests/utils/helpers.tsx @@ -12,11 +12,6 @@ import { useCallback, useEffect, useRef } from 'react' import { Provider } from 'react-redux' import { act, cleanup } from '@testing-library/react' -import { - createConsole, - getLog, - mockConsole, -} from 'console-testing-library/pure' export const ANY = 0 as any @@ -124,54 +119,6 @@ ${actions.map((a) => a.type).join('\n')}`, }, }) -declare global { - namespace jest { - interface Matchers { - toHaveConsoleOutput(expectedOutput: string): Promise - } - } -} - -function normalize(str: string) { - return str - .normalize() - .replace(/\s*\r?\n\r?\s*/g, '') - .trim() -} - -expect.extend({ - async toHaveConsoleOutput( - fn: () => void | Promise, - expectedOutput: string, - ) { - const restore = mockConsole(createConsole()) - await fn() - const { log } = getLog() - restore() - - if (normalize(log) === normalize(expectedOutput)) - return { - message: () => `Console output matches -=== -${expectedOutput} -===`, - pass: true, - } - else - return { - message: () => `Console output -=== -${log} -=== -does not match -=== -${expectedOutput} -===`, - pass: false, - } - }, -}) - export const actionsReducer = { actions: (state: UnknownAction[] = [], action: UnknownAction) => { // As of 2.0-beta.4, we are going to ignore all `subscriptionsUpdated` actions in tests diff --git a/yarn.lock b/yarn.lock index e88f6db1e1..d6db6d22a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6690,7 +6690,6 @@ __metadata: "@typescript-eslint/eslint-plugin": "npm:^6" "@typescript-eslint/parser": "npm:^6" axios: "npm:^0.19.2" - console-testing-library: "patch:console-testing-library@npm%3A0.6.1#~/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch" esbuild: "npm:^0.23.0" esbuild-extra: "npm:^0.4.0" eslint: "npm:^7.25.0" @@ -11846,28 +11845,6 @@ __metadata: languageName: node linkType: hard -"console-testing-library@npm:0.6.1": - version: 0.6.1 - resolution: "console-testing-library@npm:0.6.1" - dependencies: - jest-snapshot: "npm:^26.0.0" - pretty-format: "npm:^26.0.0" - strip-ansi: "npm:^6.0.0" - checksum: 10/3af3dc42fbc00673cd05bcda6c0deffe60f2339d511abebc839447490567728de8c5cfeaaa3eb98125e96d30e1920442d21476eddaac38837cfde397086cf8cc - languageName: node - linkType: hard - -"console-testing-library@patch:console-testing-library@npm%3A0.6.1#~/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch": - version: 0.6.1 - resolution: "console-testing-library@patch:console-testing-library@npm%3A0.6.1#~/.yarn/patches/console-testing-library-npm-0.6.1-4d9957d402.patch::version=0.6.1&hash=95f56b" - dependencies: - jest-snapshot: "npm:^26.0.0" - pretty-format: "npm:^26.0.0" - strip-ansi: "npm:^6.0.0" - checksum: 10/2947f9733979954c144c687260e58cc58f31a5cd911ebadb00e06e9fc0a280d636171f9675f72cc60d7cf5f03323a1f79fadf9965617579e031b326d3565000f - languageName: node - linkType: hard - "constant-case@npm:^3.0.4": version: 3.0.4 resolution: "constant-case@npm:3.0.4"