[READ-ONLY] Mirror of https://github.com/vitest-dev/vitest. Next generation testing framework powered by Vite. vitest.dev
test testing-tools vite
12

Configure Feed

Select the types of activity you want to include in your feed.

fix: print uint and buffer as a simple string (#8141)

authored by

Vladimir and committed by
GitHub
(Jun 10, 2025, 1:24 PM +0200) b86bf0d9 44940d9d

+23 -1
+6
packages/utils/src/error.ts
··· 60 60 if (typeof val !== 'object') { 61 61 return val 62 62 } 63 + if (typeof Buffer !== 'undefined' && val instanceof Buffer) { 64 + return `<Buffer(${val.length}) ...>` 65 + } 66 + if (typeof Uint8Array !== 'undefined' && val instanceof Uint8Array) { 67 + return `<Uint8Array(${val.length}) ...>` 68 + } 63 69 // cannot serialize immutables as immutables 64 70 if (isImmutable(val)) { 65 71 return serializeValue(val.toJSON(), seen)
+16
test/cli/test/print-error.test.ts
··· 41 41 Serialized Error: { stack: [ 'custom stack 1', 'custom stack 2' ] } 42 42 `.trim()) 43 43 }) 44 + 45 + test('prints buffer and UintArray', async () => { 46 + const { stderr } = await runInlineTests({ 47 + 'basic.test.ts': ` 48 + test('failed test', () => { 49 + throw { 50 + buffer: Buffer.from([1, 2, 3]), 51 + uintarray: Uint8Array.from([1, 2, 3]), 52 + } 53 + }) 54 + `, 55 + }, { globals: true }) 56 + 57 + expect(stderr).toContain(`buffer: '<Buffer(3) ...>'`) 58 + expect(stderr).toContain(`uintarray: '<Uint8Array(3) ...>'`) 59 + })
+1 -1
packages/vitest/src/node/printError.ts
··· 130 130 : stacks.find((stack) => { 131 131 try { 132 132 return ( 133 - project.server 133 + project._vite 134 134 && project.getModuleById(stack.file) 135 135 && existsSync(stack.file) 136 136 )