1
Jest
を使用してReact
のテストを作成しようとしています。しかし、私は次のエラーを取得しています:Jestテストに失敗しました - type.toUpperCaseは関数ではありません
TypeError: type.toUpperCase is not a function
は(images.js)リアクト:
import React, { Component } from 'react';
export class Images extends Component {
render() {
return (
<div class="images">
</div>
);
}
}
テスト(冗談):
jest.autoMockOff();
import React from 'react';
import TestUtils from 'react-addons-test-utils';
const ImagesComponent = require('../src/Components/images');
describe('ImagesComponent',() => {
it('Render instance of div class=images in DOM',() => {
const shallowRenderer = TestUtils.createRenderer();
shallowRenderer.render(<ImagesComponent className="images" />);
imagesDivComponent = shallowRenderer.getRenderOutput();
expect(imagesDivComponent.props.className).toEqual('images');
});
});
?そのコードの部分はあなたの質問には載っていません。 –
私はそうではありません、それは問題です。私はReactコンポーネントを定義する方法を変更し、 'var Images = React.createClass({export classの代わりに{module} .exports = Images;'を最後に追加します – DorianHuxley