test-utils icon indicating copy to clipboard operation
test-utils copied to clipboard

error.vue can't be tested

Open martinsjek opened this issue 1 year ago • 3 comments

Environment

StackBlitz

Reproduction

https://stackblitz.com/edit/github-vy6psx-sn3lfr?file=.nuxtignore,error.vue,tests%2Ferror.spec.ts

Describe the bug

I get this error: [Vue Router warn]: No match found for location with path "/123" [Vue warn]: Cannot mutate <script setup> binding "error" from Options API. at <MountSuspendedComponent error= { url: '/123', statusCode: 404, statusMessage: 'Not Found', message: 'Error', description: '' } > at <MountSuspendedHelper> at <Anonymous ref="VTU_COMPONENT" > at <VTUROOT> [Vue warn]: Unhandled error during execution of render function at <MountSuspendedComponent error= { url: '/123', statusCode: 404, statusMessage: 'Not Found', message: 'Error', description: '' } > at <MountSuspendedHelper> at <Anonymous ref="VTU_COMPONENT" > at <VTUROOT>

Additional context

You can get this error running: npm run test ./tests/error.spec.ts

Logs

No response

martinsjek avatar Feb 27 '24 09:02 martinsjek

Same issue, reproduces when you have useError composable inside of your component, without it test passes

vhovorun avatar May 07 '24 20:05 vhovorun

Got the same error trying to test overwritten ProseImg component.

[Vue warn]: Cannot mutate <script setup> binding "url" from Options API. 
  at <RenderSuspendedComponent url="https://hatrabbits.com/wp-content/uploads/2017/01/random.jpg" > 

DariaYeremina avatar Sep 24 '24 16:09 DariaYeremina

Same as https://github.com/nuxt/test-utils/issues/684 ?

strokirk avatar Oct 22 '24 08:10 strokirk

Environment

StackBlitz

Reproduction

https://stackblitz.com/edit/github-vy6psx-sn3lfr?file=.nuxtignore,error.vue,tests%2Ferror.spec.ts

Describe the bug

I get this error: [Vue Router warn]: No match found for location with path "/123" [Vue warn]: Cannot mutate <script setup> binding "error" from Options API. at <MountSuspendedComponent error= { url: '/123', statusCode: 404, statusMessage: 'Not Found', message: 'Error', description: '' } > at <MountSuspendedHelper> at <Anonymous ref="VTU_COMPONENT" > at <VTUROOT> [Vue warn]: Unhandled error during execution of render function at <MountSuspendedComponent error= { url: '/123', statusCode: 404, statusMessage: 'Not Found', message: 'Error', description: '' } > at <MountSuspendedHelper> at <Anonymous ref="VTU_COMPONENT" > at <VTUROOT>

Additional context

You can get this error running: npm run test ./tests/error.spec.ts

Logs

No response

I got the same error with a props name error in my component when I tested using mountSuspended from @nuxt/test-utils/runtime. To resolve it, I have just changed it to errorMessage. Maybe the test engine has a constraint with the name error .

I suggest changing the name error to a context name like 404.vue.

IT-WIBRC avatar Nov 27 '24 12:11 IT-WIBRC

This should now be resolved in https://github.com/nuxt/test-utils/pull/1025.

danielroe avatar Dec 04 '24 16:12 danielroe