jest icon indicating copy to clipboard operation
jest copied to clipboard

pass startedAt onTestCaseResult

Open RahulARanger opened this issue 1 year ago • 1 comments

Summary

This PR is to provide the started timestamp inside of the TestCaseResult object passed in custom reporter's onTestCaseResult

  • Passed started timestamp in parseSingleTestResult
  • Typings: Added started type in TestCaseResult Object

if we modify AssertionCountsReporter in e2e/customReporters

 onTestCaseResult(test, testCaseResult) {
    console.log(
      `onTestCaseResult: ${testCaseResult.title}, ` +
        `status: ${testCaseResult.status}, ` +
        `numExpectations: ${new Date(testCaseResult.startedAt)}`,
    );
  }

then notice we would get startedAt in onTestCaseResult

Determining test suites to run...onTestCaseResult: adds fail, status: failed, numExpectations: Sun Jun 23 2024 02:02:39 GMT+0530 (India Standard Time)
onTestFileResult testCaseResult 0: adds fail, status: failed, numExpectations: 0
onTestFileResult testCaseResult 0: sample, status: pending, numExpectations: 0
onTestCaseResult: test 1, status: passed, numExpectations: Sun Jun 23 2024 02:02:39 GMT+0530 (India Standard Time)
onTestCaseResult: test 2, status: passed, numExpectations: Sun Jun 23 2024 02:02:39 GMT+0530 (India Standard Time)
onTestFileResult testCaseResult 0: test 1, status: passed, numExpectations: 1    
onTestFileResult testCaseResult 1: test 2, status: passed, numExpectations: 1    
onTestCaseResult: adds ok, status: passed, numExpectations: Sun Jun 23 2024 02:02:39 GMT+0530 (India Standard Time)
onTestFileResult testCaseResult 0: adds ok, status: passed, numExpectations: 3
onTestCaseResult: sample, status: todo, numExpectations: Sun Jun 23 2024 02:02:40 GMT+0530 (India Standard Time)
onTestFileResult testCaseResult 0: sample, status: todo, numExpectations: 0

Test plan

should not break existing tests

RahulARanger avatar Jun 22 '24 20:06 RahulARanger

Deploy Preview for jestjs ready!

Name Link
Latest commit 550dfba10dd587046f42603f4dae2285c099eabe
Latest deploy log https://app.netlify.com/sites/jestjs/deploys/6696d63a47548e000830f240
Deploy Preview https://deploy-preview-15145--jestjs.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.

netlify[bot] avatar Jun 22 '24 20:06 netlify[bot]

reverting changelog as it would cause merge conflict;

changelog added;

  • [jest-circus, jest-test-result] Pass startedAt timestamp in TestCaseResultObject seen in onTestCaseResult (#15145)

RahulARanger avatar Jul 15 '24 20:07 RahulARanger

sure, will add a test case.

RahulARanger avatar Jul 16 '24 10:07 RahulARanger

https://github.com/jestjs/jest/releases/tag/v30.0.0-alpha.6

SimenB avatar Aug 08 '24 07:08 SimenB

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

github-actions[bot] avatar Sep 08 '24 00:09 github-actions[bot]