Skip to content

Commit 1fa694d

Browse files
fix: add console spy
1 parent 76b3d45 commit 1fa694d

File tree

1 file changed

+23
-0
lines changed
  • packages/@lwc/integration-not-karma/helpers

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { spyOn } from '@vitest/spy';
2+
3+
/**
4+
* A much simplified version of the spies originally used for Karma.
5+
* Should probably be eventually replaced with individual spies.
6+
*/
7+
export function spyConsole() {
8+
const log = spyOn(console, 'log');
9+
const warn = spyOn(console, 'warn');
10+
const error = spyOn(console, 'error');
11+
return {
12+
calls: {
13+
log: log.mock.calls,
14+
warn: warn.mock.calls,
15+
error: error.mock.calls,
16+
},
17+
reset() {
18+
log.mockRestore();
19+
warn.mockRestore();
20+
error.mockRestore();
21+
},
22+
};
23+
}

0 commit comments

Comments
 (0)