chai-enzyme icon indicating copy to clipboard operation
chai-enzyme copied to clipboard

.should.have.html(...) broken in 1.0.0-beta.1

Open johnomalley opened this issue 6 years ago • 0 comments

I upgraded from beta.0 to beta.1 and a test case broke. This snippet demonstrates the bug:

import React from 'react'
import chai from 'chai'
import chaiAsPromised from 'chai-as-promised'
import sinonChai from 'sinon-chai'
import sinon from 'sinon'
import chaiEnzyme from 'chai-enzyme'
import Enzyme, { shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'

global.should = chai.should()
global.expect = chai.expect
chai.use(chaiAsPromised)
chai.use(sinonChai)
chai.use(chaiEnzyme())

global.sinon = sinon
Enzyme.configure({adapter: new Adapter()})

describe.only('Example', () => {
  it('does not compare with html', () => {
    const wrapper = shallow(
      <div>
        <div className='example'/>
      </div>
    )

    wrapper.find('.example').should.have.html('<div class="example"/>')
  })
})

output:

 0 passing (523ms)
  1 failing

  1) Example
       does not compare with html:

      AssertionError: expected the node in <div /> to be '<div class="example"/>', but it was '<div className="example" />'      
     
     HTML:
     
     <div className="example" />
      + expected - actual

      -<div className="example" />
      +<div class="example"/>

relevant dependencies:

{
  "devDependencies": {
    "chai": "~4.1.2",
    "chai-as-promised": "~7.1.1",
    "chai-enzyme": "~1.0.0-beta.1",
    "enzyme": "~3.3.0",
    "enzyme-adapter-react-16": "~1.1.1",
    "mocha": "~5.2.0",
    "react": "~16.4.1",
    "react-dom": "~16.4.1",
    "react-router-dom": "~4.3.1",
    "react-test-renderer": "~16.4.1",
    "sinon": "~6.1.3",
    "sinon-chai": "~3.2.0"
  }
}

johnomalley avatar Jul 11 '18 18:07 johnomalley