Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Give more informative message with expect_named() #2091

Copy link
Copy link
@EmilHvitfeldt

Description

@EmilHvitfeldt
Issue body actions

Currently expect_identical() gives a much more informative error when some is wrong compared to expect_named()

library(testthat)

x <- list(a = 1, b = 2, d = 3)

expect_identical(names(x), c("a", "b", "c"))
#> Error: names(x) not identical to c("a", "b", "c").
#> 1/3 mismatches
#> x[3]: "d"
#> y[3]: "c"
expect_named(x, c("a", "b", "c"))
#> Error: Names of `x` ('a', 'b', 'd') don't match 'a', 'b', 'c'

Created on 2025-07-01 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.