Skip to content

Commit e3c5837

Browse files
committed
Add patch for console-testing-library to fix ESM + Vitest usage
1 parent 34ce9b5 commit e3c5837

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
diff --git a/src/index.js b/src/index.js
2+
index 90ff7fa3d7d4fa62dbbf638958ae4e28abd089a8..28434687b5163b7472e86bdb11bed69e0868e660 100644
3+
--- a/src/index.js
4+
+++ b/src/index.js
5+
@@ -1,4 +1,4 @@
6+
-import { mockConsole, createConsole } from './pure';
7+
+import { mockConsole, createConsole } from './pure.js';
8+
9+
// Keep an instance of the original console and export it
10+
const originalConsole = global.console;
11+
diff --git a/src/pure.js b/src/pure.js
12+
index b00ea2abbaea833e336676aa46e7ced2d59d6d88..42b83ed83fa16cf2234571500fe09868debd9f01 100644
13+
--- a/src/pure.js
14+
+++ b/src/pure.js
15+
@@ -228,10 +228,11 @@ export function restore() {
16+
global.console = global.originalConsole;
17+
}
18+
19+
+/*
20+
if (typeof expect === 'function' && typeof expect.extend === 'function') {
21+
expect.extend({
22+
toMatchInlineSnapshot(received, ...args) {
23+
- /* ------- Workaround for custom inline snapshot matchers ------- */
24+
+ // Workaround for custom inline snapshot matchers
25+
const error = new Error();
26+
const stacks = error.stack.split('\n');
27+
28+
@@ -245,7 +246,6 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
29+
error.stack = stacks.join('\n');
30+
31+
const context = Object.assign(this, { error });
32+
- /* -------------------------------------------------------------- */
33+
34+
const testingConsoleInstance =
35+
(received && received.testingConsole) || received;
36+
@@ -270,3 +270,4 @@ if (typeof expect === 'function' && typeof expect.extend === 'function') {
37+
},
38+
});
39+
}
40+
+*/
41+
\ No newline at end of file

0 commit comments

Comments
 (0)