我正在尝试为组件编写测试用例。测试用例正在通过。但是 JS lint 困扰着我。它抛出一个错误 - :期望一个赋值或函数调用,而是看到一个表达式
错误来了:expect(dummyOutput.find('h1.screen-reader-text')).to.exist;
我完整的测试用例代码如下。任何人都可以在这里帮我解决错误吗?
import React from 'react';
import { shallow } from 'enzyme';
import Page from './page';
const props = {
pageLayout: 'article',
theme: 'test-theme',
header: {},
footer: {},
singleAds: {},
siteMeta: { copyright_text: '©COPYRIGHT CONTENT HERE' },
};
const dummyProps = {
pageLayout: 'dummy_text',
theme: 'test-theme',
header: {},
footer: {},
singleAds: {},
siteMeta: { copyright_text: '©COPYRIGHT CONTENT HERE' },
};
const specs = () => describe('Page Layout', () => {
describe('Renders', () => {
const wrapper = shallow(<Page {...props} />);
const dummyOutput = shallow(<Page {...dummyProps} />);
it.only('should not return H1 tag', () => {
expect(wrapper.find('h1.screen-reader-text')).not.exist;
});
it.only('should return H1 tag', () => {
expect(dummyOutput.find('h1.screen-reader-text')).to.exist;
});
});
});
if (process.env.NODE_ENV === 'test') {
specs();
}
export default specs;