Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ describe('mountSuspended() compatible to mount()', () => {
const nWrapper = await mountSuspended(Component)

await expect(async () => await vWrapper.setData({ data1: '1' })).rejects
.toThrowError(/Cannot add property data1/)
.toThrow(/Cannot add property data1/)
await expect(async () => await nWrapper.setData({ data1: '1' })).rejects
.toThrowError(/Cannot add property data1/)
.toThrow(/Cannot add property data1/)
})

it.runIf(!Component.setup)('works if setup is absent', async () => {
Expand Down
10 changes: 5 additions & 5 deletions examples/app-vitest-full/tests/nuxt/fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,12 @@ describe('server mocks and data fetching', () => {
})

await expect(fetch<unknown>('/error')).rejects.toMatchObject({ status: 500, statusText: 'Mock Server Error' })
await expect(fetch<unknown>('/error', { baseURL: '"INVALID"' })).rejects.toThrowError()
await expect(fetch<unknown>('/error', { baseURL: '"INVALID"' })).rejects.toThrow()

expect(onRequest).toBeCalledTimes(4)
expect(onResponse).toBeCalledTimes(3)
expect(onRequestError).toBeCalledTimes(1)
expect(onResponseError).toBeCalledTimes(1)
expect(onRequest).toHaveBeenCalledTimes(4)
expect(onResponse).toHaveBeenCalledTimes(3)
expect(onRequestError).toHaveBeenCalledTimes(1)
expect(onResponseError).toHaveBeenCalledTimes(1)
})

it('should mock request only once with once option', async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/nuxt/middleware.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('middleware', () => {

it('can mock composable inside global middleware', async () => {
const { count } = useGlobalCounter()
expect(incrementMock).not.toBeCalled()
expect(incrementMock).not.toHaveBeenCalled()

await navigateTo({ path: '/', force: true })

Expand Down
8 changes: 4 additions & 4 deletions examples/app-vitest-full/tests/nuxt/mock-vue-router.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ describe('Index', async () => {
path: '/123',
}))

expect(useRouteMock).not.toBeCalled()
expect(useVueRouteMock).not.toBeCalled()
expect(useRouteMock).not.toHaveBeenCalled()
expect(useVueRouteMock).not.toHaveBeenCalled()

const wrapper = await mountSuspended(Index)
expect(wrapper.html()).toMatchSnapshot()

expect(useRouteMock).toBeCalled()
expect(useVueRouteMock).toBeCalled()
expect(useRouteMock).toHaveBeenCalled()
expect(useVueRouteMock).toHaveBeenCalled()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ describe('mountSuspended handle error', () => {
await expect(() => mountSuspended(TestComponent, { route: 'throws-on-router' })).rejects.toThrow('throws on router')
await nextTick()

expect(setupFn).not.toBeCalled()
expect(setupFn).not.toHaveBeenCalled()
expect(
consoleWarn.mock.calls.flat().map(String).join('\n'),
).not.toContain('[Vue warn]: Component is missing template or render function')
Expand Down
22 changes: 11 additions & 11 deletions examples/app-vitest-full/tests/nuxt/mount-suspended.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ describe('mountSuspended', () => {
],
}
`)
expect(onCustomEvent).toBeCalledTimes(1)
expect(onCustomEvent).toBeCalledWith('foo')
expect(onCustomEvent).toHaveBeenCalledTimes(1)
expect(onCustomEvent).toHaveBeenCalledWith('foo')
})

it('can receive emitted events from components using defineModel', () => {
Expand All @@ -135,8 +135,8 @@ describe('mountSuspended', () => {
})
component.find('button#changeModelValue').trigger('click')
expect(component.emitted()).toHaveProperty('update:modelValue')
expect(onUpdateModelValue).toBeCalledTimes(1)
expect(onUpdateModelValue).toBeCalledWith(true)
expect(onUpdateModelValue).toHaveBeenCalledTimes(1)
expect(onUpdateModelValue).toHaveBeenCalledWith(true)
})

it('can receive emitted events from components mounted within nuxt suspense using defineModel', async () => {
Expand All @@ -146,8 +146,8 @@ describe('mountSuspended', () => {
})
await component.find('button#changeModelValue').trigger('click')
expect(component.emitted()).toHaveProperty('update:modelValue')
expect(onUpdateModelValue).toBeCalledTimes(1)
expect(onUpdateModelValue).toBeCalledWith(true)
expect(onUpdateModelValue).toHaveBeenCalledTimes(1)
expect(onUpdateModelValue).toHaveBeenCalledWith(true)
})

it('can receive emitted events from components mounted within nuxt suspense using defineModel after prop changes and multiple interactions', async () => {
Expand All @@ -166,8 +166,8 @@ describe('mountSuspended', () => {
],
}
`)
expect(onUpdateModelValue).toBeCalledTimes(1)
expect(onUpdateModelValue).toBeCalledWith(true)
expect(onUpdateModelValue).toHaveBeenCalledTimes(1)
expect(onUpdateModelValue).toHaveBeenCalledWith(true)

await component.setProps({ modelValue: true })

Expand All @@ -181,7 +181,7 @@ describe('mountSuspended', () => {
],
}
`)
expect(onUpdateModelValue).toBeCalledTimes(1)
expect(onUpdateModelValue).toHaveBeenCalledTimes(1)

await component.setProps({ modelValue: false })

Expand All @@ -198,8 +198,8 @@ describe('mountSuspended', () => {
],
}
`)
expect(onUpdateModelValue).toBeCalledTimes(2)
expect(onUpdateModelValue).toBeCalledWith(true)
expect(onUpdateModelValue).toHaveBeenCalledTimes(2)
expect(onUpdateModelValue).toHaveBeenCalledWith(true)
})

it('can pass onUpdate event to components using defineModel', async () => {
Expand Down
2 changes: 1 addition & 1 deletion examples/app-vitest-full/tests/nuxt/plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ describe('plugins', () => {
const { count, increment } = useNuxtApp().$counter

expect(count.value).toBe(100)
expect(incrementMock).not.toBeCalled()
expect(incrementMock).not.toHaveBeenCalled()

expect(increment()).toBe(100)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ describe('renderSuspended handle error', () => {
await expect(() => renderSuspended(TestComponent, { route: 'throws-on-router' })).rejects.toThrow('throws on router')
await nextTick()

expect(setupFn).not.toBeCalled()
expect(setupFn).not.toHaveBeenCalled()
expect(
consoleWarn.mock.calls.flat().map(String).join('\n'),
).not.toContain('[Vue warn]: Component is missing template or render function')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ describe('renderSuspended', () => {
],
}
`)
expect(onCustomEvent).toBeCalledTimes(1)
expect(onCustomEvent).toBeCalledWith('foo')
expect(onCustomEvent).toHaveBeenCalledTimes(1)
expect(onCustomEvent).toHaveBeenCalledWith('foo')
})

it('can receive emitted events from components rendered within nuxt suspense using defineModel', async () => {
Expand All @@ -150,8 +150,8 @@ describe('renderSuspended', () => {

const emittedEvents = emitted()
expect(emittedEvents['update:modelValue']).toEqual([[true]])
expect(onUpdateModelValue).toBeCalledTimes(1)
expect(onUpdateModelValue).toBeCalledWith(true)
expect(onUpdateModelValue).toHaveBeenCalledTimes(1)
expect(onUpdateModelValue).toHaveBeenCalledWith(true)
})

it('should define $attrs', async () => {
Expand Down
10 changes: 5 additions & 5 deletions examples/nitro-v3/test/nuxt/fetch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ describe('registerEndpoint tests', () => {
})

await expect(fetch<unknown>('/error')).rejects.toMatchObject({ status: 500, statusText: 'Mock Server Error' })
await expect(fetch<unknown>('/error', { baseURL: '"INVALID"' })).rejects.toThrowError()
await expect(fetch<unknown>('/error', { baseURL: '"INVALID"' })).rejects.toThrow()

expect(onRequest).toBeCalledTimes(4)
expect(onResponse).toBeCalledTimes(3)
expect(onRequestError).toBeCalledTimes(1)
expect(onResponseError).toBeCalledTimes(1)
expect(onRequest).toHaveBeenCalledTimes(4)
expect(onResponse).toHaveBeenCalledTimes(3)
expect(onRequestError).toHaveBeenCalledTimes(1)
expect(onResponseError).toHaveBeenCalledTimes(1)
})

it('should mock request only once with once option', async () => {
Expand Down
Loading