Skip to content

Commit bed54f7

Browse files
committed
Suppress console.warn noise in nonce-scrub spec
scrubScriptElements warns on every removed script, so three of the four scrubScriptElements cases printed to stderr. Mocks and restores console.warn around that describe block to keep test output pristine, matching the convention already used in the sibling describe block added for the same module's caller.
1 parent e26f7f7 commit bed54f7

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

frontend/src/turbo/csp-script-nonce.spec.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
//++
2828

2929
import {
30-
afterEach, describe, expect, it,
30+
afterEach, beforeEach, describe, expect, it, vi,
3131
} from 'vitest';
3232
import { readScriptNonce, scrubScriptElements } from './csp-script-nonce';
3333

@@ -48,6 +48,14 @@ describe('readScriptNonce', () => {
4848
});
4949

5050
describe('scrubScriptElements', () => {
51+
beforeEach(() => {
52+
vi.spyOn(console, 'warn').mockImplementation(() => undefined);
53+
});
54+
55+
afterEach(() => {
56+
vi.restoreAllMocks();
57+
});
58+
5159
function scriptWithNonce(nonce:string | null):HTMLScriptElement {
5260
const script = document.createElement('script');
5361
if (nonce !== null) {

0 commit comments

Comments
 (0)