Skip to content

[Feature Proposal][circus] Add assertion events to jest-circus or event custom events #10059

@Bnaya

Description

@Bnaya

🚀 Feature Proposal

Add assertion events to jest circus,
and expose api for custom assertion libraries to emit events as-well

Motivation

Jest circus events provide valuable info during test execution.
I believe that adding events for assertions will give even a better picture of what's going on during the event execution.
My personal motivation is that I'm writing a tool that extends jest to show additional information on test runs & during test runs, and to be able to also show successful assertions.
Without standard way from jest side, I would have to wrap the assertion library myself.

That can be helpful to various tools,
And maybe even solve things like:
#6295 (comment)

Example

I don't have something very solid in mind, but if we take a look at:

Very crud dump of jest circus events during test run:

setup
add_hook
start_describe_definition hey
add_test yo
add_test oops
finish_describe_definition hey
run_start
run_describe_start
run_describe_start
test_start yo
hook_start
hook_success yo
test_fn_start yo
test_fn_success yo
test_done yo
test_start oops
hook_start
hook_success oops
test_fn_start oops
test_fn_failure oops
test_done oops
run_describe_finish
run_describe_finish
run_finish
teardown

The events i'm thinking about are (They must be sync, the return promise api is not applicable here unfortunately):

assertion_start 
assertion_failure / assertion_success
assertion_end

With additional metadata that would make sense there

Pitch

I think the power of jest-circus is the best pitch :)
Exposing more information as events from the test runs and even custom events, will give more power to external tools without the need to to integrate with the core directly, monkey patch or wrap things etc

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions