diff --git a/packages/test-utils/src/wrapper.js b/packages/test-utils/src/wrapper.js index 237abce2c..5b8ba5b63 100644 --- a/packages/test-utils/src/wrapper.js +++ b/packages/test-utils/src/wrapper.js @@ -223,10 +223,10 @@ export default class Wrapper implements BaseWrapper { * Returns HTML of element as a string */ html(options?: HtmlOptions): string { - if (options && options.prettyPrint) { - return pretty(this.element.outerHTML) + if (options && !options.prettyPrint) { + return this.element.outerHTML } - return this.element.outerHTML + return pretty(this.element.outerHTML) } /** diff --git a/test/specs/mount.spec.js b/test/specs/mount.spec.js index 792b23118..f59176c0e 100644 --- a/test/specs/mount.spec.js +++ b/test/specs/mount.spec.js @@ -340,7 +340,8 @@ describeRunIf(process.env.TEST_ENV !== 'node', 'mount', () => { if (vueVersion > 2.3) { expect(wrapper.vm.$attrs).to.eql({ height: '50px', extra: 'attr' }) } - expect(wrapper.html()).to.equal( + const htmlOptions = { prettyPrint: false } + expect(wrapper.html(htmlOptions)).to.equal( `
prop1
bar,123
bar,123
bar
bar
1,foo
') + expect(notDestructuringWrapper.html(htmlOptions)).to.equal('1,foo
') } ) @@ -112,7 +113,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(destructuringWrapper.html()).to.equal('1,foo
') + expect(destructuringWrapper.html(htmlOptions)).to.equal('1,foo
') const notDestructuringWrapper = mountingMethod( { @@ -130,7 +131,7 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { } } ) - expect(notDestructuringWrapper.html()).to.equal('1,foo
') + expect(notDestructuringWrapper.html(htmlOptions)).to.equal('1,foo
') } ) @@ -145,38 +146,38 @@ describeWithShallowAndMount('scopedSlots', mountingMethod => { noProps: 'baz
' } }) - expect(wrapper.find('#destructuring').html()).to.equal( + expect(wrapper.find('#destructuring').html(htmlOptions)).to.equal( '0,1
1,2
2,3
0,a1
1,a2
2,a3
abc
baz
0,4
1,5
2,6
0,b1
1,b2
2,b3
ABC
baz
bar
bar
bar,123
bar,123
world
' } }) - expect(wrapper.html()).to.contain('hello') - expect(wrapper.html()).to.contain('world
') + expect(wrapper.html(htmlOptions)).to.contain('hello') + expect(wrapper.html(htmlOptions)).to.contain('world
') }) it('mounts component with default and named text slot', () => { @@ -496,7 +498,7 @@ describeWithShallowAndMount('options.slots', mountingMethod => { c => c.$options.name === childComponentName ) ).to.equal(true) - expect(ParentComponent.html()).to.equal( + expect(ParentComponent.html(htmlOptions)).to.equal( '1234
1234
Hello
World