Test timed out
baixiaoyu2997 opened this issue Β· comments
Environment
@nuxt/test-utils: 3.9.0
- Operating System: Darwin
- Node Version: v18.19.0
- Nuxt Version: 3.9.1
- CLI Version: 3.10.0
- Nitro Version: 2.8.1
- Package Manager: pnpm@8.6.9
- Builder: -
- User Config: extends, pages, app, sourcemap, alias, nitro, devtools, imports, ignore, modules, vite, future, typescript
- Runtime Modules: @vueuse/nuxt@10.7.1
- Build Modules: -
Reproduction
test file:
import { it, expect, describe, beforeEach } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import { mount, config } from '@vue/test-utils'
import { createRouter, createWebHistory } from 'vue-router'
import { nextTick } from 'vue'
import SearchHash from '../SearchHash.vue'
config.global.mocks = {
$t: (text: string) => text,
}
describe('SearchHash.vue', () => {
it('Do nothing when the value is empty', async () => {
const wrapped = await mountSuspended(SearchHash, {
props: {
modelValue: '123',
},
})
expect(wrapped.props('modelValue')).toEqual('123')
})
})
component file:
<template>
<div class="y-search-hash">123</div>
</template>
<script setup lang="ts">
// The parent component calls the element-ui component method through ref.value.elRef.xxx
</script>
Describe the bug
Timeout occurs when i set i18n
in config.global.mocks
, but when I delete them, timeout does not appear.
Additional context
No response
Logs
<Suspense> is an experimental feature and its API will likely change.
stderr | components/search-hash/tests/SearchHash.test.ts > SearchHash.vue > Do nothing when the value is empty
[Vue warn]: Cannot mutate <script setup> binding "$t" from Options API.
at <MountSuspendedComponent modelValue="123" >
at <MountSuspendedHelper>
at <Anonymous ref="VTU_COMPONENT" >
at <VTUROOT>
[Vue warn]: Unhandled error during execution of render function
at <MountSuspendedComponent modelValue="123" >
at <MountSuspendedHelper>
at <Anonymous ref="VTU_COMPONENT" >
at <VTUROOT>
β― components/search-hash/tests/SearchHash.test.ts (1) 5014ms
β― SearchHash.vue (1) 5012ms
Γ Do nothing when the value is empty 5012ms
β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β― Failed Tests 1 β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―
FAIL components/search-hash/tests/SearchHash.test.ts > SearchHash.vue > Do nothing when the value is empty
Error: Test timed out in 5000ms.
If this is a long-running test, pass a timeout value as the last argument or configure it globally with "testTimeout".
β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―[1/1]β―
β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β― Unhandled Errors β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―
Vitest caught 1 unhandled error during the test run.
This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β― Unhandled Rejection β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―
TypeError: 'set' on proxy: trap returned falsish for property '$t'
β― Proxy.clonedComponent.render node_modules/.pnpm/@nuxt+test-utils@3.9.0_@testing-library+vue@8.0.1_@vue+test-utils@2.4.3_h3@1.10.0_happy-dom@1_xuvhyamayffigtvh2cst6xvzk4/node_modules/@nuxt/test-utils/dist/runtime-utils/index.mjs:128:44
126| renderContext[key] = passedProps[key];
127| }
128| return render.call(this, renderContext, ...args);
| ^
129| } : void 0,
130| setup: setup ? (props2) => wrappedSetup(props2, setupContext) : void 0
β― renderComponentRoot node_modules/.pnpm/@vue+runtime-core@3.4.10/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:874:16
β― ReactiveEffect.componentUpdateFn [as fn] node_modules/.pnpm/@vue+runtime-core@3.4.10/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:5931:46
β― ReactiveEffect.run node_modules/.pnpm/@vue+reactivity@3.4.10/node_modules/@vue/reactivity/dist/reactivity.cjs.js:179:19
β― instance.update node_modules/.pnpm/@vue+runtime-core@3.4.10/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6062:16
β― setupRenderEffect node_modules/.pnpm/@vue+runtime-core@3.4.10/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:6072:5
β― node_modules/.pnpm/@vue+runtime-core@3.4.10/node_modules/@vue/runtime-core/dist/runtime-core.cjs.js:1622:9
This error originated in "components/search-hash/tests/SearchHash.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
The latest test that might've caused the error is "Do nothing when the value is empty". It might mean one of the following:
- The error was thrown, while Vitest was running this test.
- This was the last recorded test before the error was thrown, if error originated after test finished its execution.
β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―β―
Test Files 1 failed (1)
Tests 1 failed (1)
Errors 1 error
Start at 11:16:15
Duration 5.92s
FAIL Tests failed. Watching for file changes...
press h to show help, press q to quit
No response
i have anoher issue, but i'm not sure it's a bug, when i use mountSuspended
, will Received undefined
describe('SearchHash.vue', () => {
it('Do nothing when the value is empty', async () => {
const wrapped = await mountSuspended(SearchHash, {
props: {
modelValue: '123',
},
})
expect(wrapped.props('modelValue')).toEqual('123')
})
})
but when i changed to mount
, it Received 123
:
describe('SearchHash.vue', () => {
it('Do nothing when the value is empty', () => {
const wrapped = mount(SearchHash, {
props: {
modelValue: '123',
},
})
expect(wrapped.props('modelValue')).toEqual('123')
})
})
Would you be able to provide a reproduction? π
More info
Why do I need to provide a reproduction?
Reproductions make it possible for us to triage and fix issues quickly with a relatively small team. It helps us discover the source of the problem, and also can reveal assumptions you or we might be making.
What will happen?
If you've provided a reproduction, we'll remove the label and try to reproduce the issue. If we can, we'll mark it as a bug and prioritise it based on its severity and how many people we think it might affect.
If needs reproduction
labeled issues don't receive any substantial activity (e.g., new comments featuring a reproduction link), we'll close them. That's not because we don't care! At any point, feel free to comment with a reproduction and we'll reopen it.
How can I create a reproduction?
We have a couple of templates for starting with a minimal reproduction:
π https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-vitest
π https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/app-jest
π https://stackblitz.com/github/nuxt/test-utils/tree/main/examples/module
A public GitHub repository is also perfect. π
Please ensure that the reproduction is as minimal as possible. See more details in our guide.
You might also find these other articles interesting and/or helpful: