我使用浅层创建了一个在本地运行良好的测试,但是当它在bitbucket中的circleci中运行时,pull请求并没有起作用。当我将测试更改为使用mount时,它在本地和circleci中工作正常。任何人都知道这个的原因吗?
原始测试:
import React from 'react'
import { shallow } from 'enzyme'
import { Dashboard } from './../Dashboard'
describe('Dashboard', () => {
const wrapper = shallow(<Dashboard />)
it('has a header', () => {
const currentHeader = wrapper.find('Header')
expect(currentHeader.length).toEqual(1)
})
it('has a subHeader', () => {
const currentSubHeader = wrapper.find('SubHeader')
expect(currentSubHeader.length).toEqual(1)
})
it('has a content', () => {
const currentContent = wrapper.find('.sn-layout__content')
expect(currentContent.length).toEqual(1)
})
})
修改测试:
import React from 'react'
import { mount } from 'enzyme'
import { Dashboard } from './../Dashboard'
describe('Dashboard', () => {
const wrapper = mount(<Dashboard />)
it('has a header', () => {
const currentHeader = wrapper.find('.sn-layout__header')
expect(currentHeader.length).toEqual(1)
})
it('has a subHeader', () => {
const currentSubHeader = wrapper.find('.sn-layout__subheader')
expect(currentSubHeader.length).toEqual(1)
})
it('has a content', () => {
const currentContent = wrapper.find('.sn-layout__content')
expect(currentContent.length).toEqual(1)
})
})