Skip to content

Comments

feat(reporters): support custom options#5111

Merged
AriPerkkio merged 1 commit intovitest-dev:mainfrom
AriPerkkio:feat/reporter-options
Feb 5, 2024
Merged

feat(reporters): support custom options#5111
AriPerkkio merged 1 commit intovitest-dev:mainfrom
AriPerkkio:feat/reporter-options

Conversation

@AriPerkkio
Copy link
Member

@AriPerkkio AriPerkkio commented Feb 4, 2024

Description

There are now multiple different ways how to define reporters in configuration. This is similar shape as coverage.reporters has.

// A single reporter by name
{ reporters: "junit" },

// Inline reporter
{ reporters: { onFinished() { method(); } } },

// A single reporter with options - new option style 
{ reporters: [["junit", { classname: "some-junit-thing", outputFile: "report.xml" }]] },

// Multiple reporters - can combine any of the above
{ 
  reporters: [
    "verbose",
    ["json"],
    ["junit", { classname: "some-junit-thing" } ],
    { onFinished() { method(); } },
    "vitest-github-actions-reporter", // Third party reporter by package name
    "/path/to/local/reporter.js", // Local reporter by path
    ["vitest-sonar-reporter", { silent: true }], // Third party reporter by with options
  ]
},
  • junit reporter's process.env.VITEST_JUNIT_CLASSNAME and process.env.VITEST_JUNIT_SUITE_NAME can now be passed via reporter options: ["junit", { classname: "..." suiteName: "..." }]. In 2.0.0 we should drop support for the environment variables.
  • test.outputFile can now be passed as reporter option, e.g. ["json", { outputFile: "report.json" }]. I think in 2.0.0 we should drop support for test.outputFile completely.

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

netlify bot commented Feb 4, 2024

Deploy Preview for fastidious-cascaron-4ded94 ready!

Name Link
🔨 Latest commit de2c1b3
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/65c0fc28b7372b0008e7b53d
😎 Deploy Preview https://deploy-preview-5111--fastidious-cascaron-4ded94.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 site configuration.

@AriPerkkio AriPerkkio force-pushed the feat/reporter-options branch 3 times, most recently from 28e1088 to 5bd7427 Compare February 4, 2024 13:25
@AriPerkkio AriPerkkio force-pushed the feat/reporter-options branch from 5bd7427 to e4f530f Compare February 4, 2024 16:49
@AriPerkkio AriPerkkio marked this pull request as ready for review February 4, 2024 16:55
@AriPerkkio AriPerkkio force-pushed the feat/reporter-options branch from e4f530f to 4bf04b2 Compare February 4, 2024 16:58
@AriPerkkio AriPerkkio requested a review from dammy001 February 4, 2024 16:58
@AriPerkkio AriPerkkio force-pushed the feat/reporter-options branch from 4bf04b2 to 22fcad4 Compare February 4, 2024 17:02
sheremet-va
sheremet-va previously approved these changes Feb 5, 2024
@AriPerkkio AriPerkkio force-pushed the feat/reporter-options branch from 22fcad4 to de2c1b3 Compare February 5, 2024 15:17
@AriPerkkio AriPerkkio merged commit fec9ca0 into vitest-dev:main Feb 5, 2024
@AriPerkkio AriPerkkio deleted the feat/reporter-options branch February 5, 2024 15:56
@sheremet-va sheremet-va added this to the 1.3.0 milestone Feb 9, 2024
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.

support reporter options

2 participants