Error: Invalid Chai property: toBe. Did you mean "to"?

11,049

As you are using the 'chai-as-promised' plug-in that extends Chai with a fluent language for asserting facts about promises. You do have to adjust the assertions slightly. The below page gives good examples. Chai as promised page with explanations

For your issue you will need to change:

.isPresent()).toBe(true);

to:

.isPresent()).to.eventually.equal(true);

Therefore your assertion should look like this:

expect(element(by.id(dropdown)).isPresent()).to.eventually.equal(true);

Also note I have not seen the use of .equals only .equal

Share:
11,049

Related videos on Youtube

Alfredo Bazo Lopez
Author by

Alfredo Bazo Lopez

Updated on June 04, 2022

Comments

  • Alfredo Bazo Lopez
    Alfredo Bazo Lopez almost 2 years

    I am trying to check that an element is present in an angular website. I am using protractor 5.4.0.

    In the header of the my_steps.js file I have this:

    global.expect = require('chai').expect
    var chai = require('chai');
    var chaiAsPromised = require('chai-as-promised');
    chai.use(chaiAsPromised);
    

    The code that I am using to assert that the dropdown is present is:

    Then(/^(.*) is present$/, function (dropdown,callback) {
            expect(element(by.id(dropdown)).isPresent()).toBe(true);
            callback();
    

    And the output of the protractor protractor.conf.js command is:

    When application opened # ../Features/step_definitions/my_steps.js:62
       ✖ Then templateSelection is present # ../Features/step_definitions/my_steps.js:70
           Error: Invalid Chai property: toBe. Did you mean "to"?
    

    What am I doing wrong?

    Thanks in advance.