Search code examples
javascriptunit-testingsupertest

Expect libarary TypeError: expect(...).toInclude is not a function


I'm guessing it's an import error somehow, but I can't seem to figure out how, expect is up to date and I can't get it too run without it saying

libarary TypeError: expect(...).toInclude is not a function

var request = require("supertest");
var {app} = require("./../server.js");
var {Show} = require("./../models/show");
var expect = require('expect');

    describe("GET /show/:id", () => {
        it("Should include the show name 'Arrow' in the body", (done) => {
            request(app)
            .get(`/show/${showName}`)
            .expect(200)
            .expect((res) => {
                expect('hello world').toInclude('world')

            })
            .end(done);
        });
    })

});

Solution

  • The expect library was recently made part of the Jest project - the Jest team changed the API a little, as this answer explains.

    The full documentation for expect can now be found here: https://facebook.github.io/jest/docs/en/expect.html