vitest-dev / vitest-dev/vitest
verbose reporter on CI shows multiple lines for single test with async `afterEach` or fixture teardown
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 17.1k
- Forks
- 2k
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 94
Description
Describe the bug
For this test file:
//// test/after-each-ok.test.ts
import { afterEach, test } from 'vitest';
afterEach(async () => {
await new Promise((resolve) => setTimeout(resolve, 500));
});
test('some-test', () => {});
Verbose reporter shows this log when CI is enabled:
$ CI=1 npx vitest --reporter=verbose
...
✓ test/after-each-ok.test.ts > some-test
✓ test/after-each-ok.test.ts > some-test
I created a repro here with four cases (afterEach ok/error, fixture teardown ok/error) https://stackblitz.com/edit/vitest-dev-vitest-gtq5a4?file=test%2Fafter-each-ok.test.ts
It could be a limitation of onTaskUpdate based reporter implementation, but I thought it's worth raising an issue since I was confused by this when debugging CI verbose reporter. This is coincidentally reproducible on Vitest core test:
$ CI=1 pnpm -C test/core test test-extend.test.ts -- --reporter=verbose -t 'asynchonous setup/teardown'
...
RUN v1.1.3 /home/hiroshi/code/others/vitest/test/core
✓ test/test-extend.test.ts > asynchonous setup/teardown > quick test
✓ test/test-extend.test.ts > asynchonous setup/teardown > quick test
Test Files 1 passed (1)
Tests 1 passed | 17 skipped (18)
Start at 10:09:46
Duration 768ms (transform 68ms, setup 16ms, collect 42ms, tests 405ms, environment 0ms, prepare 71ms)
Reproduction
https://stackblitz.com/edit/vitest-dev-vitest-gtq5a4?file=test%2Fafter-each-ok.test.ts
System Info
(stackblitz)
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 18.18.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 9.4.2 - /usr/local/bin/npm
pnpm: 8.14.0 - /usr/local/bin/pnpm
npmPackages:
@vitest/ui: latest => 1.1.3
vite: latest => 5.0.11
vitest: latest => 1.1.3
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reproduction in test/after-each-ok.test.ts and the asynchronous setup/teardown case in test/test-extend.test.ts. Run the provided CI verbose-reporter commands and compare the output across the afterEach and fixture teardown cases; done means each test is reported once while preserving the relevant pass or failure status.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100