Skip to content

Commit

Permalink
test: add failing test pending upstream vue fix
Browse files Browse the repository at this point in the history
  • Loading branch information
danielroe committed May 17, 2023
1 parent 8907546 commit 23a701c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions test/basic.test.ts
Expand Up @@ -596,6 +596,15 @@ describe('navigate', () => {
})
})

describe('preserves current instance', () => {
it('should not return getCurrentInstance when there\'s an error in data', async () => {
await fetch('/instance/error')
const html = await $fetch('/instance/next-request')
// TODO: this needs to be fixed upstream in Vue: https://github.com/vuejs/core/issues/7733, https://github.com/vuejs/core/pull/7743
expect(html).not.toContain('This should be false: false')
})
})

describe('errors', () => {
it('should render a JSON error page', async () => {
const res = await fetch('/error', {
Expand Down
13 changes: 13 additions & 0 deletions test/fixtures/basic/pages/instance/error.vue
@@ -0,0 +1,13 @@
<script lang="ts">
export default defineComponent({
data () {
throw new Error('💀')
}
})
</script>

<template>
<div>
This should not display.
</div>
</template>
5 changes: 5 additions & 0 deletions test/fixtures/basic/pages/instance/next-request.vue
@@ -0,0 +1,5 @@
<template>
<div>
This should be false: {{ $wasVueAppInstanceWronglyPreserved }}
</div>
</template>
9 changes: 9 additions & 0 deletions test/fixtures/basic/plugins/context-error.ts
@@ -0,0 +1,9 @@
export default defineNuxtPlugin(() => {
// this should be undefined
const vueApp = getCurrentInstance()
return {
provide: {
wasVueAppInstanceWronglyPreserved: !!vueApp
}
}
})

0 comments on commit 23a701c

Please sign in to comment.