Adam Jenkins
Adam Jenkins

Reputation: 55613

babel-jest can't find https

I am using jest/babel-jest to write a node application, am using https module.

babel.config.js

module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        targets: {
          node: 'current',
        },
      },
    ],
  ],
};

Test file:

import { https } from 'https';

// do some stuff

https.request(...);

But when I run jest I get this:

TypeError: Cannot read property 'request' of undefined

Why won't jest let me make an http request?

I know I'm doing something stupid, I just don't know what :P

Upvotes: 0

Views: 39

Answers (1)

Rajan Lagah
Rajan Lagah

Reputation: 2528

Try

import https from 'https';

Upvotes: 1

Related Questions