Skip to content

Provide a way to block and wait for a promise (for testing) #48

Open
@antoine-sachet

Description

@antoine-sachet

In some context, it would be useful to be able to block and wait for a promise to be resolved or rejected.

Typically, I want to test with testthat some code that acts on futures or promises, so I want to synchronously check that the resolved value is correct. The future API offers the value method but it is not implemented by promises.

I see how you solved this with the extract function in tests/testthat/common.R. It would be useful to have access to this blocking extract function from the package, without confusing the end-users who shouldn't use it.

How about as a non-exported function such as promises:::extract_block or promises:::value?

Or maybe it would be neater if testthat was promise-aware, with e.g. expect_promise_resolved and expect_promise_rejected?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions