0

I'm using chai 4.2.0 and is not working as expected, this is the example.

Receiving this TypeError: expect is not a function and wondering why if I'm using a global variable.

var chai = require('chai');
var expect = chai.expect;

describe("Homepage FAQ Accordion", function () {
    beforeEach(function() {

        console.log(expect.expect);
        browser.url('http://127.0.0.1:8303/');
   })

it("should show first section on page load", function() {

var firstHeight = browser.getCssProperty(".accordion .accordion-item:first-child .accordion-content", "height");

        var firstHeight = browser.getTitle();

        console.log(firstHeight);

        expect(firstHeight.parsed.value).to.be.greaterThan(0);
    })
it("should not show other content", function() {
        var secondHeight = browser.getCssProperty(".accordion .accordion-item:nth-of-type(2) .accordion-content", "Display")

        console.log(secondDisplay);

        expect(secondDisplay.parsed.value).to.equal(none);

    })
})

techgamer
  • 1
  • 2
  • 2
    You never define `expect`? I'm surprised this doesn't throw a `ReferenceError: expect is not defined` – VLAZ Feb 11 '20 at 22:27
  • You've overridden/shadowed `expect` with something else than a function in the scope the provided example runs. Please add some more code so, that we can see how the scopes are constructed. – Teemu Feb 11 '20 at 22:30
  • Thank you guys, I've added the entire code I have for this issue. – techgamer Feb 11 '20 at 22:50
  • 1
    Have you checked what is the value of `expect` after assigned `chai.expect` to it? – Teemu Feb 11 '20 at 22:54

0 Answers0