Skip to content

Fix flaky test #3689

Description

@shuuji3

The same test failure frequently occurs on CI recently. In most case, rerun of the CI just resolves the error but we're not sure which updates started causing this error.

Example: https://github.com/elk-zone/elk/actions/runs/30148126012/job/89653702566?pr=3687

Run pnpm test:ci
$ vitest run

 RUN  v4.1.9 /home/runner/work/elk/elk

Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
stdout | ../tests/nuxt/content-rich.test.ts
<Suspense> is an experimental feature and its API will likely change.

stdout | ../tests/nuxt/html-parse.test.ts
<Suspense> is an experimental feature and its API will likely change.

stdout | ../tests/unit/reorder-timeline.test.ts
<Suspense> is an experimental feature and its API will likely change.

 ✓  nuxt  ../tests/unit/reorder-timeline.test.ts (2 tests) 10ms
 ✓  nuxt  ../tests/nuxt/html-parse.test.ts (10 tests) 110ms
Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
 ✓  nuxt  ../tests/nuxt/content-rich.test.ts (27 tests) 233ms
Importing from "vitest/environments" is deprecated since Vitest 4.1. Please use "vitest/runtime" instead.
The Vitest environment nuxt defines the "transformMode". This options was deprecated in Vitest 4 and will be removed in the next major version. Please, use "viteEnvironment" instead.
stdout | ../tests/unit/permalinks.test.ts
<Suspense> is an experimental feature and its API will likely change.

 ✓  nuxt  ../tests/unit/permalinks.test.ts (6 tests) 5ms
stdout | ../tests/unit/language.test.ts
<Suspense> is an experimental feature and its API will likely change.

 ✓  nuxt  ../tests/unit/language.test.ts (1 test) 13ms
stdout | ../tests/nuxt/html-to-text.test.ts
<Suspense> is an experimental feature and its API will likely change.

 ✓  nuxt  ../tests/nuxt/html-to-text.test.ts (3 tests) 11ms
⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯

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.

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
EnvironmentTeardownError: Cannot load '/components/status/StatusCard.vue' imported from /home/runner/work/elk/elk/app/components/timeline/TimelinePaginator.vue after the environment was torn down. This is not a bug in Vitest. The last recorded callstack:
- /components/status/StatusCard.vue
- /home/runner/work/elk/elk/app/components/timeline/TimelinePaginator.vue
- /home/runner/work/elk/elk/app/components/timeline/TimelinePublicLocal.vue
- /home/runner/work/elk/elk/app/pages/[[server]]/public/local.vue
- virtual:nuxt:%2Fhome%2Frunner%2Fwork%2Felk%2Felk%2Fnode_modules%2F.cache%2Fnuxt%2F.nuxt%2Froutes.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/nuxt@4.4.7_@babel+plugin-syntax-jsx@7.29.7_@babel+core@7.29.0__@babel+plugin-syntax-typ_e65ea5674bab43264150363baa09017d/node_modules/nuxt/dist/pages/runtime/plugins/router.js
- virtual:nuxt:%2Fhome%2Frunner%2Fwork%2Felk%2Felk%2Fnode_modules%2F.cache%2Fnuxt%2F.nuxt%2Fplugins.client.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/nuxt@4.4.7_@babel+plugin-syntax-jsx@7.29.7_@babel+core@7.29.0__@babel+plugin-syntax-typ_e65ea5674bab43264150363baa09017d/node_modules/nuxt/dist/app/nuxt-vitest-app-entry.js
- /home/runner/work/elk/elk/node_modules/.pnpm/@nuxt+test-utils@3.19.2_@vue+test-utils@2.4.11_@vue+compiler-dom@3.5.38_@vue+server-ren_5d8fd7dcb5980ff1c2656f1fa40234b7/node_modules/@nuxt/test-utils/dist/runtime/shared/nuxt.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/@nuxt+test-utils@3.19.2_@vue+test-utils@2.4.11_@vue+compiler-dom@3.5.38_@vue+server-ren_5d8fd7dcb5980ff1c2656f1fa40234b7/node_modules/@nuxt/test-utils/dist/runtime/entry.mjs
 ❯ app/components/timeline/TimelinePaginator.vue:2:31
 ❯ app/components/timeline/TimelinePublicLocal.vue:2:31

This error originated in "tests/nuxt/html-parse.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.

⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
EnvironmentTeardownError: Cannot load '/components/account/AccountAvatar.vue' imported from /home/runner/work/elk/elk/app/components/account/AccountInlineInfo.vue after the environment was torn down. This is not a bug in Vitest. The last recorded callstack:
- /components/account/AccountAvatar.vue
- /home/runner/work/elk/elk/app/components/account/AccountInlineInfo.vue
- /home/runner/work/elk/elk/app/components/status/StatusReplyingTo.vue
- /home/runner/work/elk/elk/app/components/status/StatusCard.vue
- /home/runner/work/elk/elk/app/components/timeline/TimelinePaginator.vue
- /home/runner/work/elk/elk/app/components/timeline/TimelinePublicLocal.vue
- /home/runner/work/elk/elk/app/pages/[[server]]/public/local.vue
- virtual:nuxt:%2Fhome%2Frunner%2Fwork%2Felk%2Felk%2Fnode_modules%2F.cache%2Fnuxt%2F.nuxt%2Froutes.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/nuxt@4.4.7_@babel+plugin-syntax-jsx@7.29.7_@babel+core@7.29.0__@babel+plugin-syntax-typ_e65ea5674bab43264150363baa09017d/node_modules/nuxt/dist/pages/runtime/plugins/router.js
- virtual:nuxt:%2Fhome%2Frunner%2Fwork%2Felk%2Felk%2Fnode_modules%2F.cache%2Fnuxt%2F.nuxt%2Fplugins.client.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/nuxt@4.4.7_@babel+plugin-syntax-jsx@7.29.7_@babel+core@7.29.0__@babel+plugin-syntax-typ_e65ea5674bab43264150363baa09017d/node_modules/nuxt/dist/app/nuxt-vitest-app-entry.js
- /home/runner/work/elk/elk/node_modules/.pnpm/@nuxt+test-utils@3.19.2_@vue+test-utils@2.4.11_@vue+compiler-dom@3.5.38_@vue+server-ren_5d8fd7dcb5980ff1c2656f1fa40234b7/node_modules/@nuxt/test-utils/dist/runtime/shared/nuxt.mjs
- /home/runner/work/elk/elk/node_modules/.pnpm/@nuxt+test-utils@3.19.2_@vue+test-utils@2.4.11_@vue+compiler-dom@3.5.38_@vue+server-ren_5d8fd7dcb5980ff1c2656f1fa40234b7/node_modules/@nuxt/test-utils/dist/runtime/entry.mjs
 ❯ app/components/account/AccountInlineInfo.vue:2:31
 ❯ app/components/status/StatusReplyingTo.vue:2:31

This error originated in "tests/nuxt/html-to-text.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯


 Test Files  6 passed (6)
      Tests  49 passed (49)
     Errors  2 errors
   Start at  06:48:26
   Duration  9.60s (transform 15.13s, setup 17.17s, import 2.10s, tests 382ms, environment 3.76s)

[ELIFECYCLE] Command failed with exit code 1.
Error: Process completed with exit code 1.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: chorePR that doesn't affect the runtime behavior

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions