reactjs - 酶找不到类
问题描述
那是<Foo />
我要测试的组件
...
return (
<span
className={`foo ${a === 'b' ? 'bar' : ''} ${className}`}>
{kitten === 'cats' ?
<Cat
... />
:
<Dog
... />
}
<div
className={
`find-me
${foo === 'bar' ? 'abc' : 'def'}
${cats}
${dogs}`
}>
{
children.map((obj, index) => {
...
}
</div>
</span>
...
这就是我尝试测试的方式
it('constructs correctly when there are three children rendered', () => {
const component = mount(
<Foo >
{options}
</Foo>
);
expect(component.find('.find-me').children()).to.have.lengthOf(3);
component.unmount();
});
但我明白了
TypeError:无法读取未定义的属性“拥有”
为什么找不到类?
解决方案
推荐阅读
- azure-devops - 如果 nuget 包不是最新的,如何制动管道?
- javascript - Material-UI DataGrid:我们能否在 Material-UI DataGrid 中展开折叠每一行
- python - 在 Python 的“点击”提示中自动回答“是”(无人值守的命令运行)
- python - 在 Fastapi 中将依赖/依赖项放在哪里进行身份验证?
- jsonata - 如何通过某些表达式 JSONATA 重命名字段或聚合
- google-ads-api - 如何从 Google AdSense 获取网站特定 URL 的统计信息?
- java - 在 H2 内存数据库的 liquibase 迁移中找不到列
- sql - 如何根据条件将额外的 AND 语句附加到 WHERE 子句?
- javascript - 在 drawEmpty 函数中未定义的 Highcharts
- c++ - c ++初学者,string.replace,代码编译但终止 - 你如何用另一个字符替换数字?