잼 작업을 꿀꺽 꿀꺽 작업으로 실행하면 처음에는 항상 실패로 간주되지만 테스트는 정상적으로 실행 된 것처럼 보입니다. 문제가있는 곳을 잘 모르겠습니다.jasmine jsdom과 효소가있는 반응 테스트 구성 요소가있는 경우 true가 될 것으로 예상됩니다
는 구성 요소
import React, { PropTypes } from 'react';
const propTypes = {};
const defaultProps = {};
class Foo extends React.Component {
constructor(props) {
super(props);
}
render() {
return (
<div className="foo"> </div>
);
}
}
Foo.propTypes = propTypes;
Foo.defaultProps = defaultProps;
export default Foo;
사양이 파일 반작용
import React from 'react';
import { shallow, mount, render } from 'enzyme';
import Foo from './foo.react';
import jsDom from 'jsdom';
global.document = jsDom.jsdom('');
global.window = document.defaultView;
Object.keys(document.defaultView).forEach((property) => {
if (typeof global[property] === 'undefined') {
global[property] = document.defaultView[property];
}
});
global.navigator = {
userAgent: 'node.js'
};
describe("A suite", function() {
it("contains spec with an expectation", function() {
console.log(shallow(<Foo />));
expect(shallow(<Foo />).contains(<div className="foo" />)).toBe(true);//.toBe(true)
});
it("contains spec with an expectation", function() {
expect(shallow(<Foo />).is('.foo')).toBe(true);
});
it("contains spec with an expectation", function() {
expect(mount(<Foo />).find('.foo').length).toBe(1);
});
});
결과 내가 <div className="foo" />
대신,932 나의 복귀를 변경해야 밖으로 찾을 수