babel-jest找不到https

时间:2019-10-06 02:34:24

标签: node.js jestjs

我正在使用jest / babel-jest编写节点应用程序,正在使用https模块。

babel.config.js

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

测试文件:

import { https } from 'https';

// do some stuff

https.request(...);

但是当我开玩笑的时候我得到了:

TypeError: Cannot read property 'request' of undefined

为什么不开玩笑让我发出http请求?

我知道我在做一些愚蠢的事情,我只是不知道什么:P

1 个答案:

答案 0 :(得分:1)

尝试

import https from 'https';
相关问题