Skip to content

expect_type(..., "promise") fails because of evaluating a promise #2330

@ErdaradunGaztea

Description

@ErdaradunGaztea

(I have testthat v3.3.2 installed)

It seems that it's not possible to test for "promise" type of an object using expect_type(). I've dug down and the issue lies in quasi_label(), then labelled_value(), and finally in this line calling list(val = value, lab = label), where value is a promise that gets therefore evaluated. I have no idea how to fix it at the moment.

A reprex:

x <- environment()
delayedAssign("q", {
    message("Promise evaluated")
    1
}, assign.env = x)
testthat::expect_type(x[["q"]], "promise")
#> Promise evaluated
#> Error:
#> ! Expected `x[["q"]]` to have type "promise".
#> Actual type: "double"

Created on 2026-04-08 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions