Closed topd5 closed 8 months ago
you will have to do something like this:
import {chai as chaiModule} from 'chai';
const chai = chaiModule.use(chaiHttp);
Thanks, but this is not a solution.
import { expect, use, request } from 'chai';
SyntaxError: The requested module 'chai' does not provide an export named 'request'
request
is not part of chai
, it is part of chai-http
. One of the breaking changes in v5 of Chai is that it no longer re-exposes exports from libraries. You'll need to do this:
import { expect, use } from 'chai';
import { request } from 'chai-http';
@keithamus It doesn't work:
import chaiHttp, { request } from 'chai-http';
^^^^^^^
SyntaxError: Named export 'request' not found.
In "node_modules/chai-http/lib/http.js" there is code:
module.exports = function (chai, _) {
// ...
chai.request = require('./request');
If you follow @43081j's notes and avoid importing request:
import {chai as chaiModule} from 'chai';
const chai = chaiModule.use(chaiHttp);
const request = chai.request;
Thank you. The way it helped:
import * as chaiModule from 'chai';
const chai = chaiModule.use(chaiHttp);
then usage:
const resp = await chai.request(app)
// ...
Chai was updated to 5th version. With new version
chai-http
doesn't work:How to use it with 5th version of chai?