node.js - babel-jest 找不到 https
问题描述
我正在使用 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
解决方案
尝试
import https from 'https';
推荐阅读
- excel - 跨多个工作表操作数据
- android - 生成签名包:构建包文件时出错。'other' 有不同的词根
- css - SCSS & 和多个父选择器
- aws-iot - AWS IoT - SQL 问题 - 从“*”创建 JSON
- php - 在 Laravel 中打印行数
- next.js - NextJS getStaticProps 中的 API 调用导致错误 500
- html - 如何使用 css 在列中居中两行?
- aframe - A 帧:禁用
在 AR 模式下 - pentaho - pentaho 解析参数信息时出错
- docker - 我的 docker 容器如何通过域名请求主机上的本地网络服务器?