I'm looking to read the result of custom matcher from a custom reporter
in the codebase I found this https://github.com/facebook/jest/blob/master/packages/expect/src/index.js#L274
so it should already be possible, but i cannot find where in a custom reporter this data is available.
more details at https://github.com/americanexpress/jest-image-snapshot/issues/51#issuecomment-452699525
this is where reporters are called, but looking at the types i cannot find the result of the matcher
https://github.com/facebook/jest/blob/665a93eec70c4f2d7809d1848fbc8ca60cfd8361/packages/jest-cli/src/ReporterDispatcher.js
@kandros it'd be great if you could follow the issue template. In particular, what do you need it for?
It's lost here: https://github.com/facebook/jest/blob/722049ccd66947d48296dcb666bc99fccab86065/packages/jest-jasmine2/src/reporter.js#L148-L183
and here: https://github.com/facebook/jest/blob/722049ccd66947d48296dcb666bc99fccab86065/packages/jest-circus/src/utils.js#L307-L331
@thymikee @rickhanlonii seems like something we should be able to keep in the results object, no? Just keep matcherResult around if it's a property of the error we get in.
@SimenB I copied the wrong link, (edited first post)
this is the one correct https://github.com/americanexpress/jest-image-snapshot/issues/51#issuecomment-452699525
I need to be able to pass custom data from a matcher to a reporter, in the linked example (when result object gets added in the retun value of the matcher along pass and message).
This allows me to have a custom reporter that show the image (the path is in the result)
I also need this information to build a custom watch plugin
PR welcome 馃檪 Adding it to this type makes sense to me: https://github.com/facebook/jest/blob/722049ccd66947d48296dcb666bc99fccab86065/types/TestResult.js#L102-L112
If the underlying error has matcherResult add it, otherwise set it to null
Thanks @SimenB
I can take it, not sure what to do with circus, can you point me to circus's equivalent of jest/packages/jest-jasmine2/src/reporter.js?
It's in that utils file I linked to. It has on real equivalent, but that function does essentially the same as the specResult.failedExpectations.forEach part of jasmine's reporter
Note that to run circus locally, set JEST_CIRCUS=1 in the terminal. Other than that, I think CONTRIBUTING.md has all the details 馃檪
@SimenB
Can I try to contribute to this feature please ?
@rpgeeganage due to lack of time I wasn't able to continue that, but I started working on it in January (it was before typescript rewrite, not sure if my changes still make sense) I'm going to check if something can still be used/useful as a start
@kandros ,
Thanks a lot. I would like to carry on working this.
@kandros ,
Can you please give me a branch or commit which I can take a look at?
(it will be really useful).
Thanks a lot.
@victorphoenix3 and I would love to take this up!
Wonderful! I'm fine with just adding this to jest-circus, btw - I'll land the PR making it default this week. I won't say no to a PR supporting jasmine of course, but it's not needed unless you want to 馃憤
It has been pointed out to me that this is probably solved in #9496. We are missing _succesful_ assertions, but we don't currently track those at all. I think it's natural to include those in the report data when we _do_track them though, so I'll close this.
Shout at me if anybody disagree! 馃檪
Most helpful comment
Wonderful! I'm fine with just adding this to jest-circus, btw - I'll land the PR making it default this week. I won't say no to a PR supporting jasmine of course, but it's not needed unless you want to 馃憤