diff --git a/src/index.js b/src/index.js index 5bfcec25..f3ceedc3 100644 --- a/src/index.js +++ b/src/index.js @@ -286,7 +286,7 @@ module.exports = { ); }, equal(a, b) { - return a.nodeValue === b.nodeValue; + return a.nodeType === b.nodeType && a.nodeValue === b.nodeValue; }, inspect(element, depth, output) { return output.code( diff --git a/test/index.spec.js b/test/index.spec.js index e7feb4e9..dd06ae44 100644 --- a/test/index.spec.js +++ b/test/index.spec.js @@ -1678,6 +1678,27 @@ describe('unexpected-dom', () => { ` ); }); + + describe('on nodes of different types', () => { + it('should fail', () => { + expect(() => { + expect( + parseHtmlNode( + '' + ), + 'to equal', + parseHtmlDocument( + '

Tournament

' + ) + ); + }, 'to throw an error satisfying to equal snapshot', expect.unindent` + expected + to equal ... + + Mismatching constructors HTMLUListElement should be Document + `); + }); + }); }); describe('on text nodes', () => {