Skip to content

feat: provide entity to onConsoleLog - #8159

Merged
sheremet-va merged 3 commits into
vitest-dev:mainfrom
sheremet-va:feat/provide-entity
Jun 20, 2025
Merged

sheremet-va merged 3 commits into
vitest-dev:mainfrom
sheremet-va:feat/provide-entity

Conversation

@sheremet-va

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

Copy link
Copy Markdown
Member

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:.

@netlify

netlify Bot commented Jun 13, 2025 •

Copy link
Copy Markdown

✅ 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.

@AriPerkkio AriPerkkio left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

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