Skip to content

feat: provide entity to onConsoleLog #8159

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

Merged
merged 3 commits into from
Jun 20, 2025

Conversation

sheremet-va
Copy link
Member

@sheremet-va sheremet-va commented Jun 13, 2025

Description

Fixes #8156

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 Jun 13, 2025

Deploy Preview for vitest-dev ready!

Name Link
🔨 Latest commit 409deee
🔍 Latest deploy log https://app.netlify.com/projects/vitest-dev/deploys/684c6d6775cd9a000888d6d7
😎 Deploy Preview https://deploy-preview-8159--vitest-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link
Member

@AriPerkkio AriPerkkio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Let's also update docs.

Comment on lines 436 to 438
const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : undefined
const entity = task && this.ctx.state.getReportedEntity(task)
const shouldLog = this.ctx.config.onConsoleLog?.(log.content, log.type, entity)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick, but could avoid getReportedEntity and idMap.get calls:

let shouldLog = true;

if(this.ctx.config.onConsoleLog) {
  const task = log.taskId ? this.ctx.state.idMap.get(log.taskId) : undefined
  const entity = task && this.ctx.state.getReportedEntity(task)
  shouldLog = this.ctx.config.onConsoleLog(log.content, log.type, entity)
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to decide in what version we will release this. Technically this is a feature, but I am not planning to have 3.3 (or I guess we can have a mini release?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just leave it for 4.0

@sheremet-va sheremet-va moved this to Approved in Team Board Jun 14, 2025
@sheremet-va sheremet-va added this to the 4.0.0 milestone Jun 14, 2025
@sheremet-va sheremet-va merged commit 437d461 into vitest-dev:main Jun 20, 2025
15 checks passed
@sheremet-va sheremet-va deleted the feat/provide-entity branch June 20, 2025 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add name of the test case and test module in test.onConsoleLog callbacks
2 participants