I was trying to check whether a string is present in another string. I am using the below code:


But it is giving the below error:

AssertionError: object tested must be an array, a map, an object, a set, a string, or a weakset, but object given

But when I tried with the below code, it is not throwing the above error:


I am working on protractor framework with cucumber and javascript. Could someone help to solve this issue.

2 Answers 2


You need to identify that the test shouldn't pass until the promise you're waiting on is resolved!

to.include() it does not resolve the promise

how to.include() is: Use the include matcher to specify that a collection includes one or more expected objects. It succeeds if any object of the given collection passes the specified matcher. This works on any object that responds to #include? (such as a string or array):

and the reason it passes with to.eventually.include() is it deals with promise

Promised is the eventually property. With it, you can transform any existing Chai assertion into one that acts on a promise:

if you want to.include() work why dont you simply do this may work.

    const arr = [actualTimeZone];

note : this solution is based on how your error suggest.

with this you need to resolve promise

it('xyz', (done) => {
  .then(t => {
     expect(t).then(a => to.include(y);
  • Thanks for your reply. But that change doesn't make any difference to the error.And also the other one I mentioned was to.eventually.equal , not to.eventually.include
    – RRR
    Dec 20, 2018 at 11:46
  • okay i forget to mention that either you return an array and resolve it with async/await
    – Rao
    Dec 20, 2018 at 11:50
  • i updated answer and refer this
    – Rao
    Dec 20, 2018 at 11:55

I tried using the below code and it is working


  • this is because it resolves the promise
    – Rao
    Dec 20, 2018 at 11:58
  • @RRR You should be accepting the answer that worked/helped, rather than accepting your own answer. Nov 27, 2019 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.