Я тестирую свой компонент реагирования, используя рендерер реагирующего-тест-рендеринга. все работало нормально, но после использования ReactCssTransitionGroup я получаю следующую ошибку «Ошибка типа: не удается прочитать свойство« baseVal »из неопределенного». не уверен, как решить эту проблему
Я подтвердил, что эта проблема вызвана ReactCssTransitionGroup
Ниже находится мой файл компонента:
import React from 'react';
import PropTypes from 'prop-types';
import {List, ListItem, Spinner} from '@stores/reactCommon';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
import BagListItem from './bag-list-item';
const BagList = ({bagList, loading}) => {
const items = bagList.map((item, key) => (
<ListItem key={key}>
<BagListItem
upc={item.upc}
price={item.sellingPrice}
description={item.description}
/>
</ListItem>
));
return (
<div className="bag-list">
{loading ? (
<span className="bag-list__spinner">
<Spinner size="extra-large" />
</span>
) : null}
<div className="bag-list__story-default-spacer">
<List maxHeight="70vh">
<ReactCSSTransitionGroup
transitionName="bagList"
transitionAppear={true}
transitionAppearTimeout={500}
transitionEnterTimeout={500}
transitionLeaveTimeout={300}
>
{items}
</ReactCSSTransitionGroup>
</List>
</div>
</div>
);
};
BagList.propTypes = {
bagList: PropTypes.array.isRequired,
loading: PropTypes.bool
};
export default BagList;
Ниже файл моего модульного теста
import React from 'react';
import renderer from 'react-test-renderer';
import BagList from '../../../../src/client/js/components/bag-list/bag-list';
describe('<BagList />', function() {
this.items = [
{
upc: '123222123',
sellingPrice: '12',
description: 'this is a description'
},
{
upc: '555123',
price: '23',
description: 'this is a description'
}
];
this.getComponent = items => {
return <BagList bagList={items} loading={false} />;
};
it('Should render <BagList /> with bagList', () => {
// this line is generating the error
const items = renderer.create(this.getComponent(this.items)).toJSON();
expect(items).toMatchSnapshot();
});
});