Skip to content

Obj is oneOf array of objects #1241

@simon-tannai

Description

@simon-tannai

Hi ! :)

I would to test if an object if one of entries from an array containing objects.
It's something like: expect({}).to.deep.oneOf([{}, {}, {}])

But I got this error: AssertionError: expected { Object (type, sender, ...) } to be one of [ Array(3) ]

With more details, this is the test with the object and the array:

expect({
  "type": "text",
  "sender": "bot",
  "user": "USER_TEST",
  "payload": {
    "value": "Lorem ipsum"
  }
}).to.deep.oneOf([
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Dolor sit amet"
    }
  },
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Lorem ipsum"
    }
  },
  {
    "type": "text",
    "sender": "bot",
    "user": "USER_TEST",
    "payload": {
      "value": "Consectetur adipiscing elit"
    }
  }
])

How can I do this kind of test ?

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