vitest
vitest copied to clipboard
fix(vitest): logs in `beforeAll` and `afterAll`
Description
-
Closes #3366
-
I think the reason why logs in hooks
beforeAll
andafterAll
are missing from the HTML report is because these logs are not attached to the related tasks they were contained in. https://github.com/vitest-dev/vitest/blob/5bb8b38092f107384b0fbfb091d3d60ab4ea39bd/packages/vitest/src/runtime/console.ts#L88
Here's the comparison between without and with this PR:
import { afterAll, beforeAll, describe, expect, test } from 'vitest'
beforeAll(() => {
console.log('beforeAll')
})
afterAll(() => {
console.log('afterAll')
})
describe('suite', () => {
beforeAll(() => {
console.log('beforeAll')
})
afterAll(() => {
console.log('afterAll')
})
describe('nested suite', () => {
beforeAll(() => {
console.log('beforeAll')
})
afterAll(() => {
console.log('afterAll')
})
test('test', () => {
expect(true).toBe(true)
})
})
})
Before
After
Please don't delete this checklist! Before submitting the PR, please make sure you do the following:
- [x] It's really useful if your PR references an issue where it is discussed ahead of time. If the feature is substantial or introduces breaking changes without a discussion, PR might be closed.
- [x] Ideally, include a test that fails without this PR but passes with it.
- [x] Please, don't make changes to
pnpm-lock.yaml
unless you introduce a new test example.
Tests
- [x] Run the tests with
pnpm test:ci
.
Documentation
- [ ] If you introduce new functionality, document it. You can run documentation with
pnpm run docs
command.
Changesets
- [x] Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with
feat:
,fix:
,perf:
,docs:
, orchore:
.
Deploy Preview for fastidious-cascaron-4ded94 canceled.
Name | Link |
---|---|
Latest commit | 3fc257c1361037150070f1e37d8784eecc247791 |
Latest deploy log | https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65f3f0daeacb3e0008a2088c |
@fenghan34 hey! can you fix merge conflicts when you have time, please? 🙏🏻
@fenghan34 hey! can you fix merge conflicts when you have time, please? 🙏🏻
Sure I will do it soon