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(vitest): logs in beforeAll and afterAll #5288

Merged
merged 4 commits into from
Mar 15, 2024

Conversation

fenghan34
Copy link
Contributor

@fenghan34 fenghan34 commented Feb 24, 2024

Description

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
image
image

After
image
image

Please don't delete this checklist! Before submitting the PR, please make sure you do the following:

  • 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.
  • Ideally, include a test that fails without this PR but passes with it.
  • Please, don't make changes to pnpm-lock.yaml unless you introduce a new test example.

Tests

  • 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

  • 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:, or chore:.

Copy link

netlify bot commented Feb 24, 2024

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 3fc257c
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65f3f0daeacb3e0008a2088c

@fenghan34 fenghan34 marked this pull request as ready for review February 25, 2024 04:32
sheremet-va
sheremet-va previously approved these changes Mar 14, 2024
@sheremet-va
Copy link
Member

@fenghan34 hey! can you fix merge conflicts when you have time, please? 🙏🏻

@fenghan34
Copy link
Contributor Author

@fenghan34 hey! can you fix merge conflicts when you have time, please? 🙏🏻

Sure I will do it soon

@sheremet-va sheremet-va merged commit ce5ca6b into vitest-dev:main Mar 15, 2024
17 of 19 checks passed
renovate bot referenced this pull request in Johannes-Andersen/Johannes Mar 15, 2024
[![Mend
Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com)

This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[@vitest/coverage-v8](https://togithub.com/vitest-dev/vitest/tree/main/packages/coverage-v8#readme)
([source](https://togithub.com/vitest-dev/vitest/tree/HEAD/packages/coverage-v8))
| [`1.3.1` ->
`1.4.0`](https://renovatebot.com/diffs/npm/@vitest%2fcoverage-v8/1.3.1/1.4.0)
|
[![age](https://developer.mend.io/api/mc/badges/age/npm/@vitest%2fcoverage-v8/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/@vitest%2fcoverage-v8/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/@vitest%2fcoverage-v8/1.3.1/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/@vitest%2fcoverage-v8/1.3.1/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
| [vitest](https://togithub.com/vitest-dev/vitest)
([source](https://togithub.com/vitest-dev/vitest/tree/HEAD/packages/vitest))
| [`1.3.1` ->
`1.4.0`](https://renovatebot.com/diffs/npm/vitest/1.3.1/1.4.0) |
[![age](https://developer.mend.io/api/mc/badges/age/npm/vitest/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/npm/vitest/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/npm/vitest/1.3.1/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/npm/vitest/1.3.1/1.4.0?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>vitest-dev/vitest (@&#8203;vitest/coverage-v8)</summary>

###
[`v1.4.0`](https://togithub.com/vitest-dev/vitest/releases/tag/v1.4.0)

#####    🚀 Features

- Throw error when using snapshot assertion with `not`  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5294](https://togithub.com/vitest-dev/vitest/issues/5294)
[<samp>(b9d37)</samp>](https://togithub.com/vitest-dev/vitest/commit/b9d378f5)
- Add a flag to include test location in tasks  -  by
[@&#8203;sheremet-va](https://togithub.com/sheremet-va) in
[https://github.com/vitest-dev/vitest/issues/5342](https://togithub.com/vitest-dev/vitest/issues/5342)
[<samp>(d627e)</samp>](https://togithub.com/vitest-dev/vitest/commit/d627e209)
-   **cli**:
- Support wildcards in `--project` option  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5295](https://togithub.com/vitest-dev/vitest/issues/5295)
[<samp>(201bd)</samp>](https://togithub.com/vitest-dev/vitest/commit/201bd067)
-   **config**:
- Add `shuffle.files` and `shuffle.tests` options  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5281](https://togithub.com/vitest-dev/vitest/issues/5281)
[<samp>(356db)</samp>](https://togithub.com/vitest-dev/vitest/commit/356db87b)
- Deprecate `cache.dir` option  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5229](https://togithub.com/vitest-dev/vitest/issues/5229)
[<samp>(d7e8b)</samp>](https://togithub.com/vitest-dev/vitest/commit/d7e8b53e)
-   **coverage**:
- Support `--changed` option  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5314](https://togithub.com/vitest-dev/vitest/issues/5314)
[<samp>(600b4)</samp>](https://togithub.com/vitest-dev/vitest/commit/600b44d6)
-   **vitest**:
- Support `clearScreen` cli flag  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5241](https://togithub.com/vitest-dev/vitest/issues/5241)
[<samp>(e1735)</samp>](https://togithub.com/vitest-dev/vitest/commit/e1735fb6)

#####    🐞 Bug Fixes

- Repeatable `--project` option  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5265](https://togithub.com/vitest-dev/vitest/issues/5265)
[<samp>(d1a06)</samp>](https://togithub.com/vitest-dev/vitest/commit/d1a06730)
- `--inspect-brk` to pause before execution  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5355](https://togithub.com/vitest-dev/vitest/issues/5355)
[<samp>(e77c5)</samp>](https://togithub.com/vitest-dev/vitest/commit/e77c553f)
- Correct locations in test.each tasks  -  by
[@&#8203;sheremet-va](https://togithub.com/sheremet-va)
[<samp>(4f6e3)</samp>](https://togithub.com/vitest-dev/vitest/commit/4f6e39c1)
-   **api**:
- Use resolvedUrls from devserver  -  by
[@&#8203;saitonakamura](https://togithub.com/saitonakamura) and
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5289](https://togithub.com/vitest-dev/vitest/issues/5289)
[<samp>(2fef5)</samp>](https://togithub.com/vitest-dev/vitest/commit/2fef5a7e)
-   **browser**:
- Add `magic-string` to `optimizeDeps.include`  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5278](https://togithub.com/vitest-dev/vitest/issues/5278)
[<samp>(8f04e)</samp>](https://togithub.com/vitest-dev/vitest/commit/8f04e798)
-   **coverage**:
- Expensive regexp hangs v8 report generation  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5259](https://togithub.com/vitest-dev/vitest/issues/5259)
[<samp>(d68a7)</samp>](https://togithub.com/vitest-dev/vitest/commit/d68a7390)
- V8 to ignore type-only files  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5328](https://togithub.com/vitest-dev/vitest/issues/5328)
[<samp>(c3eb8)</samp>](https://togithub.com/vitest-dev/vitest/commit/c3eb8deb)
- Respect source maps of pre-transpiled sources  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5367](https://togithub.com/vitest-dev/vitest/issues/5367)
[<samp>(6eda4)</samp>](https://togithub.com/vitest-dev/vitest/commit/6eda473f)
- Prevent `reportsDirectory` from removing user's project  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5376](https://togithub.com/vitest-dev/vitest/issues/5376)
[<samp>(07ec3)</samp>](https://togithub.com/vitest-dev/vitest/commit/07ec3779)
-   **expect**:
- Show diff on `toContain/toMatch` assertion error  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5267](https://togithub.com/vitest-dev/vitest/issues/5267)
[<samp>(8ee59)</samp>](https://togithub.com/vitest-dev/vitest/commit/8ee59f0d)
-   **forks**:
- Wrap `defines` to support `undefined` values  -  by
[@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5284](https://togithub.com/vitest-dev/vitest/issues/5284)
[<samp>(5b58b)</samp>](https://togithub.com/vitest-dev/vitest/commit/5b58b399)
-   **typecheck**:
- Update get-tsconfig 4.7.3 to fix false circularity error  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5384](https://togithub.com/vitest-dev/vitest/issues/5384)
[<samp>(bdc37)</samp>](https://togithub.com/vitest-dev/vitest/commit/bdc371ee)
-   **ui**:
- Escape html in error diff  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5325](https://togithub.com/vitest-dev/vitest/issues/5325)
[<samp>(ab60b)</samp>](https://togithub.com/vitest-dev/vitest/commit/ab60bf8d)
-   **vitest**:
- Loosen `onConsoleLog` return type  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5337](https://togithub.com/vitest-dev/vitest/issues/5337)
[<samp>(6d1b1)</samp>](https://togithub.com/vitest-dev/vitest/commit/6d1b1451)
- Ensure restoring terminal cursor on close  -  by
[@&#8203;hi-ogawa](https://togithub.com/hi-ogawa) in
[https://github.com/vitest-dev/vitest/issues/5292](https://togithub.com/vitest-dev/vitest/issues/5292)
[<samp>(0bea2)</samp>](https://togithub.com/vitest-dev/vitest/commit/0bea2247)
- Ignore timeout on websocket reporter rpc  -  by
[@&#8203;sheremet-va](https://togithub.com/sheremet-va)
[<samp>(38119)</samp>](https://togithub.com/vitest-dev/vitest/commit/38119b75)
- Correctly override api with --no-api flag  -  by
[@&#8203;sheremet-va](https://togithub.com/sheremet-va) in
[https://github.com/vitest-dev/vitest/issues/5386](https://togithub.com/vitest-dev/vitest/issues/5386)
[<samp>(51d1d)</samp>](https://togithub.com/vitest-dev/vitest/commit/51d1d472)
- Logs in `beforeAll` and `afterAll`  -  by
[@&#8203;fenghan34](https://togithub.com/fenghan34) in
[https://github.com/vitest-dev/vitest/issues/5288](https://togithub.com/vitest-dev/vitest/issues/5288)
[<samp>(ce5ca)</samp>](https://togithub.com/vitest-dev/vitest/commit/ce5ca6bf)
-   **workspace**:
- Throw error when browser mode and `@vitest/coverage-v8` are used  - 
by [@&#8203;AriPerkkio](https://togithub.com/AriPerkkio) in
[https://github.com/vitest-dev/vitest/issues/5250](https://togithub.com/vitest-dev/vitest/issues/5250)
[<samp>(29f98)</samp>](https://togithub.com/vitest-dev/vitest/commit/29f98cd3)

#####     [View changes on
GitHub](https://togithub.com/vitest-dev/vitest/compare/v1.3.1...v1.4.0)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about these
updates again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Mend
Renovate](https://www.mend.io/free-developer-tools/renovate/). View
repository job log
[here](https://developer.mend.io/github/Johannes-Andersen/Johannes).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yNDUuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI0NS4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiJ9-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
@fenghan34 fenghan34 deleted the fix/logs-in-hooks branch March 16, 2024 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Logs in beforeAll missing from HTML report
2 participants