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

feat(reporters): support custom options #5111

Merged
merged 1 commit into from
Feb 5, 2024

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

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.

sheremet-va
sheremet-va previously approved these changes Feb 5, 2024
docs/guide/reporters.md Outdated Show resolved Hide resolved
@AriPerkkio AriPerkkio merged commit fec9ca0 into vitest-dev:main Feb 5, 2024
19 checks passed
@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