简体   繁体   English

babel-jest 找不到 https

[英]babel-jest can't find https

I am using jest/babel-jest to write a node application, am using https module.我正在使用 jest/babel-jest 编写节点应用程序,正在使用https模块。

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?为什么不让我提出 http 请求?

I know I'm doing something stupid, I just don't know what:P我知道我在做一些愚蠢的事情,我只是不知道是什么:P

Try尝试

import https from 'https';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM