Open xiaodong2008 opened 3 months ago
Test Case:
test('in component event handler via emit (async)', async () => { const err = new Error('foo') const fn = vi.fn() const Comp = { setup() { onErrorCaptured((err, instance, info) => { fn(err, info) return false }) return createComponent(Child, { async onFoo() { throw err }, }) }, } const Child = { props: ['onFoo'], setup(props: any, { emit }: any) { emit('foo') }, } define(Comp).render() await nextTick() expect(fn).toHaveBeenCalledWith(err, 'setup function') })
Error:
Vitest caught 2 unhandled errors during the test run. This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected. Error: foo ❯ packages/runtime-vapor/__tests__/errorHandling.spec.ts:383:17 381| 382| test('in component event handler via emit (async)', async () => { 383| const err = new Error('foo') | ^ 384| const fn = vi.fn() 385| ❯ node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:135:14 ❯ node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:60:26 ❯ runTest node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:771:17 ❯ runSuite node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:899:15 ❯ runSuite node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:899:15 ❯ runFiles node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:948:5 ❯ startTests node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:957:3 ❯ node_modules/.pnpm/vitest@1.5.2_@types+node@20.14.2_@vitest+ui@1.6.0_jsdom@24.0.0_sass@1.77.4_terser@5.31.1/node_modules/vitest/dist/chunks/runtime-runBaseTests.-x-nNuJ_.js:116:7 ❯ withEnv node_modules/.pnpm/vitest@1.5.2_@types+node@20.14.2_@vitest+ui@1.6.0_jsdom@24.0.0_sass@1.77.4_terser@5.31.1/node_modules/vitest/dist/chunks/runtime-runBaseTests.-x-nNuJ_.js:83:5 This error originated in "packages/runtime-vapor/__tests__/errorHandling.spec.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. Error: foo ❯ packages/runtime-vapor/__tests__/errorHandling.spec.ts:383:17 381| 382| test('in component event handler via emit (async)', async () => { 383| const err = new Error('foo') | ^ 384| const fn = vi.fn() 385| ❯ node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:135:14 ❯ node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:60:26 ❯ runTest node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:771:17 ❯ runSuite node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:899:15 ❯ runSuite node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:899:15 ❯ runFiles node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:948:5 ❯ startTests node_modules/.pnpm/@vitest+runner@1.5.2/node_modules/@vitest/runner/dist/index.js:957:3 ❯ node_modules/.pnpm/vitest@1.5.2_@types+node@20.14.2_@vitest+ui@1.6.0_jsdom@24.0.0_sass@1.77.4_terser@5.31.1/node_modules/vitest/dist/chunks/runtime-runBaseTests.-x-nNuJ_.js:116:7 ❯ withEnv node_modules/.pnpm/vitest@1.5.2_@types+node@20.14.2_@vitest+ui@1.6.0_jsdom@24.0.0_sass@1.77.4_terser@5.31.1/node_modules/vitest/dist/chunks/runtime-runBaseTests.-x-nNuJ_.js:83:5 This error originated in "packages/runtime-vapor/__tests__/errorHandling.spec.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running. Test Files 1 failed (1) Tests 1 failed | 12 passed (13) Errors 2 errors Start at 13:34:46 Duration 75ms
Test Case:
Error: