Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chai import error #338

Open
rnura1234 opened this issue Aug 30, 2024 · 1 comment
Open

chai import error #338

rnura1234 opened this issue Aug 30, 2024 · 1 comment

Comments

@rnura1234
Copy link

I am import chai as chaiModule, but getting error like
import chaiModule from "chai";
^^^^^^^^^^
SyntaxError: The requested module 'chai' does not provide an export named 'default'

Code for Reference

import chaiModule from "chai";
import chaiHttp from "chai-http";

const chai = chaiModule.use(chaiHttp);
describe('Users API Testing', () => {

    it('GET all the users', (done) => {
        chai.request('http://localhost:3000')
        .get('/')
        .get('/api/users')
        .end((err, res) => {
            if (err) done(err);
            expect(res).to.have.status(200);
            expect(res.body).to.be.an('array');
            done();
        });
    });
});

and when Import like
import * as chai from 'chai',
getting error - chai.request is not a function,

I tried different way to import , but getting same error.

@43081j
Copy link
Contributor

43081j commented Aug 30, 2024

import * as chaiModule from "chai";
import chaiHttp from "chai-http";

const chai = chaiModule.use(chaiHttp);

Should work as expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants