reactjs - 无法配置酶适配器
问题描述
我正在尝试配置酶适配器进行测试。我的代码是这样的,非常简单:
import * as enzyme from 'enzyme';
import * as Adapter from 'enzyme-adapter-react-16';
enzyme.configure({adapter : new Adapter()});
我收到如下错误:
import Adapter
Cannot use 'new' with an expression whose type lacks a call or construct signature.ts(2351)
setupTests.ts(2, 1): Type originates at this import. A namespace-style import cannot be called or constructed, and will cause a failure at runtime. Consider using a default import or import require here instead.
这可能是版本问题吗?我正在关注 2 年前的 react-typescript 指南。
谢谢。
解决方案
小错误。
改变:
import * as Adapter from 'enzyme-adapter-react-16';
至:
import Adapter from 'enzyme-adapter-react-16';
推荐阅读
- python - 在 Pytorch 中重新实现矩阵分解时的问题
- python - 如何格式化参数的帮助输出?
- flutter - 即使在 ListView 内也会出现底部溢出错误
- swift - SwiftUI Horizontal ScrollView 不滚动
- javascript - 无法通过 content.js 将请求发送到 laravel 服务器
- swift - 如何获取字符串中字符的坐标(x,y)
- html - 如何在css中更正div的宽度
- java - 如何使用 Okio 正确地分块读取文件?
- php - 连接到 gmails mx 记录
- calendar - 同一时间段内的最大事件数 - Google 日历