Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky tests #4464

Open
3 tasks
sheremet-va opened this issue Nov 10, 2023 · 3 comments
Open
3 tasks

Fix flaky tests #4464

sheremet-va opened this issue Nov 10, 2023 · 3 comments

Comments

@sheremet-va
Copy link
Member

sheremet-va commented Nov 10, 2023

Clear and concise description of the problem

We disabled some flaky tests in CI, but we still need to fix them.

List of flaky tests:

@bonyuta0204
Copy link
Contributor

bonyuta0204 commented Jan 8, 2024

Failing logs for coverage-test

Logs

It can be reproduced easily by running nr test:v8 at test/coverage-test in local machine.

test/coverage-test test:  ✓ |With settings: {"pool":"threads","poolOptions":{"threads":{"singleThread":true,"isolate":true}},"directory":"test/","browser":false}| test/coverage.test.ts  (9 tests) 24ms
test/coverage-test test: stdout | setup.ts:2:9
test/coverage-test test: Test Setup File
test/coverage-test test: stdout | src/another-setup.ts:2:9
test/coverage-test test: Another Setup File
test/coverage-test test: ⎯⎯⎯⎯⎯⎯ Failed Suites 1 ⎯⎯⎯⎯⎯⎯⎯
test/coverage-test test:  FAIL  |With settings: {"pool":"threads","poolOptions":{"threads":{"singleThread":true,"isolate":true}},"directory":"test/","browser":false}| test/no-esbuild-transform.test.js [ test/no-esbuild-transform.test.js ]
test/coverage-test test: Error: [vitest] Cannot mock "../src/utils" because it is already loaded. Did you import it in a setup file?
test/coverage-test test: Please, remove the import if you want static imports to be mocked, or clear module cache by calling "vi.resetModules()" before mocking if you are going to import the file again. See: https://vitest.dev/guide/common-errors.html#cannot-mock-mocked-file.js-because-it-is-already-loaded
test/coverage-test test:  ❯ test/no-esbuild-transform.test.js:5:25
test/coverage-test test:       3| 
test/coverage-test test:       4| vi.mock('../src/utils', async () => ({
test/coverage-test test:       5|   add: vi.fn().mockReturnValue('mocked'),
test/coverage-test test:        |                         ^
test/coverage-test test:       6| }))
test/coverage-test test:       7| 
test/coverage-test test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯[1/1]⎯
test/coverage-test test: ⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
test/coverage-test test: Error: [vitest] Cannot mock "../src/utils" because it is already loaded. Did you import it in a setup file?
test/coverage-test test: Please, remove the import if you want static imports to be mocked, or clear module cache by calling "vi.resetModules()" before mocking if you are going to import the file again. See: https://vitest.dev/guide/common-errors.html#cannot-mock-mocked-file.js-because-it-is-already-loaded
test/coverage-test test:  ❯ VitestMocker.mockPath ../../packages/vitest/dist/vendor/execute.cedv4NLQ.js:304:13
test/coverage-test test:  ❯ ../../packages/vitest/dist/vendor/execute.cedv4NLQ.js:122:14
test/coverage-test test:  ❯ VitestMocker.resolveMocks ../../packages/vitest/dist/vendor/execute.cedv4NLQ.js:117:5
test/coverage-test test:  ❯ VitestExecutor.resolveUrl ../../packages/vitest/dist/vendor/execute.cedv4NLQ.js:1176:7
test/coverage-test test:  ❯ VitestExecutor.executeId ../../packages/vite-node/dist/client.mjs:164:23
test/coverage-test test:  ❯ resolveCoverageProviderModule ../../packages/vitest/dist/vendor/coverage.v6aD8iAh.js:10:41
test/coverage-test test:  ❯ takeCoverageInsideWorker ../../packages/vitest/dist/vendor/coverage.v6aD8iAh.js:40:26
test/coverage-test test: ⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯
test/coverage-test test: 
test/coverage-test test: Vitest caught 1 unhandled error during the test run.
test/coverage-test test: This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
test/coverage-test test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
test/coverage-test test:  Test Files  1 failed | 1 passed (2)
test/coverage-test test:       Tests  9 passed (9)
test/coverage-test test:      Errors  1 error
test/coverage-test test:    Start at  13:54:38
test/coverage-test test:    Duration  481ms (transform 55ms, setup 26ms, collect 59ms, tests 24ms, environment 0ms, prepare 114ms)
test/coverage-test test:  ❯ VitestTestRunner.testRunner.onAfterRunFiles ../../packages/vitest/dist/vendor/index.h0j9y5vy.js:72:22
test/coverage-test test:  ❯ startTests ../../packages/runner/dist/index.js:852:3
test/coverage-test test: JUNIT report written to /home/runner/work/vitest/vitest/test/coverage-test/coverage/junit.xml

@sheremet-va
Copy link
Member Author

Failing logs for coverage-test

This is reported as a separate issue at #4894

@bonyuta0204
Copy link
Contributor

I found another flaky test during investigation.
https://github.com/vitest-dev/vitest/actions/runs/7544433361/job/20537754611?pr=4902

test/core test: ⎯⎯⎯⎯⎯⎯ Unhandled Errors ⎯⎯⎯⎯⎯⎯
test/core test: 
test/core test: Vitest caught 2 unhandled errors during the test run.
test/core test: This might cause false positive tests. Resolve unhandled errors to make sure your tests are not affected.
test/core test: ⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
test/core test: Error: [birpc] timeout on calling "onUnhandledError"
test/core test:  ❯ Timeout._onTimeout ../../packages/vitest/dist/vendor/index.cAUulNDf.js:38:22
test/core test:  ❯ listOnTimeout node:internal/timers:569:17
test/core test:  ❯ process.processTimers node:internal/timers:512:7
test/core test: This error originated in "test/skip.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
test/core test: The latest test that might've caused the error is "correctly skips tests with async callback". It might mean one of the following:
test/core test: - The error was thrown, while Vitest was running this test.
test/core test: - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
test/core test: This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
test/core test: - cancel timeouts using clearTimeout and clearInterval
test/core test: - wait for promises to resolve using the await keyword
test/core test: ⎯⎯⎯⎯ Unhandled Rejection ⎯⎯⎯⎯⎯
test/core test: Error: [birpc] timeout on calling "onUnhandledError"
test/core test:  ❯ Timeout._onTimeout ../../packages/vitest/dist/vendor/index.cAUulNDf.js:38:22
test/core test:  ❯ listOnTimeout node:internal/timers:569:17
test/core test:  ❯ process.processTimers node:internal/timers:512:7
test/core test: This error originated in "test/skip.test.ts" test file. It doesn't mean the error was thrown inside the file itself, but while it was running.
test/core test: The latest test that might've caused the error is "correctly skips tests with async callback". It might mean one of the following:
test/core test: - The error was thrown, while Vitest was running this test.
test/core test: - If the error occurred after the test had been completed, this was the last documented test before it was thrown.
test/core test: This error was caught after test environment was torn down. Make sure to cancel any running tasks before test finishes:
test/core test: - cancel timeouts using clearTimeout and clearInterval
test/core test: - wait for promises to resolve using the await keyword
test/core test: ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
test/core test:  Test Files  110 passed (110)
test/core test:       Tests  859 passed | 60 skipped | 6 todo (926)
test/core test:      Errors  2 errors
test/core test:    Start at  16:24:29
test/core test:    Duration  70.40s (transform 3.65s, setup 2.69s, collect 9.40s, tests 8.65s, environment 1.59s, prepare 23.11s)
test/core test: Failed
/home/runner/work/vitest/vitest/test/core:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @vitest/test-core@ test: `vitest "--allowOnly" "--pool" "vmThreads"`
Exit status 1

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

No branches or pull requests

2 participants