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): show beforeAll/afterAll errors in junit reporter #4819

Merged
merged 1 commit into from
Dec 31, 2023

Conversation

hi-ogawa
Copy link
Contributor

@hi-ogawa hi-ogawa commented Dec 29, 2023

Description

Closes #4516

This PR is an alternative of #4799 to surface beforeAll/afterAll errors in junit reporter.

This approach might not be the most sound one since it "mutates" test counts when beforeAll/afterAll failed, but this will ensure such suite-level errors will be recorded in the report.

The idea came from how default reporters shows "Failed Suites" separately from "Failed Tests":

const failedSuites = suites.filter(i => i.result?.errors)
const failedTests = tests.filter(i => i.result?.state === 'fail')
const failedTotal = countTestErrors(failedSuites) + countTestErrors(failedTests)
let current = 1
const errorDivider = () => logger.error(`${c.red(c.dim(divider(`[${current++}/${failedTotal}]`, undefined, 1)))}\n`)
if (failedSuites.length) {
logger.error(c.red(divider(c.bold(c.inverse(` Failed Suites ${failedSuites.length} `)))))
logger.error()
await this.printTaskErrors(failedSuites, errorDivider)
}

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 Dec 29, 2023

Deploy Preview for fastidious-cascaron-4ded94 canceled.

Name Link
🔨 Latest commit 5ee041d
🔍 Latest deploy log https://app.netlify.com/sites/fastidious-cascaron-4ded94/deploys/658e75e5ed4f11000802672c

@hi-ogawa hi-ogawa changed the title fix(vitest): show beforeAll/afterAll errors in junit reporter fix(vitest): show beforeAll/afterAll errors in junit reporter Dec 29, 2023
@hi-ogawa hi-ogawa marked this pull request as ready for review December 29, 2023 07:43
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.

JUNIT reporter doesn't mark test as failed if the beforeAll throws error
2 participants