Skip to content

Not able to require the chai-http as commonjs() in latest version #335

@Nanagoud007

Description

@Nanagoud007

when i require module like this
const chai = require('chai');
const expect = chai.expect;
chai.use(require('chai-http'));

when i run the test case i am getting this error
my project is all depending on require so i can't go to import
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/node_modules/chai-http/index.js from /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/test/write-status-logs.test.js not supported.
Instead change the require of index.js in /home/nanagoudt/numo_backend_repos/multitenant-cpuptime-service/test/write-status-logs.test.js to a dynamic import() which is available in all CommonJS modules.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions