我想知道这是否可能和/或测试我的观点的好方法?首先,我尝试通过此基本测试,但是'App.js'父级是使用Razor传递的,它不存在...
somePage.cshtml
<div>
<h1>Some Page</h1>
@Html.React("App.Components.Faqs", new
{
somePage = Model
})
</div>
somePage.js
import React, { Component } from 'react';
import ComponentOne from './component_one';
import ComponentTwo from './component_two';
const somePage = () => {
render() {
return (
<div>
<ComponentOne/>
<ComponentTwo/>
</div>
);
}
}
somePage.test.js-我尝试的测试
import React from 'react';
import { shallow } from 'enzyme';
import App from '../App';
import ComponentOne from 'components/component_one';
import ComponentTwo from 'components/component_two';
let App;
beforeEach(() => {
component = shallow(<App />);
});
it('has one component of ComponentOne', () => {
expect(component.find(ComponentOne).length).toEqual(1);
});