You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
During the upgrade process of a project to Vue 3 & Vue Test Utils 2, I’ve noticed a failing test that’s caused by a different whitespace setting used during test execution than what’s otherwise used in the project (via compiler options set in the project’s webpack configuration).
After trying to provide a minimal reproduction, it looks like setting global.config.compilerOptions.whitespace via a mount call’s options doesn’t always work. Specifically, setting it once (to any value) seems to prevent it being set to a different value in subsequent mount calls.
To Reproduce
Run the following test code in a project with @vue/test-utils installed. Both tests should pass, but the second will fail. Note also how changing the order of the tests makes it so that the test will fail that’s now the second even though it previously passed.
const{ mount }=require('@vue/test-utils')constComponent={template: ` <div> <h2> Heading </h2> </div> `}// Skipping this test allows the second test pass. Without skipping it, the second test fails.test('works with whitespace “preserve”',()=>{constwrapper=mount(Component,{global: {config: {compilerOptions: {whitespace: 'preserve',},},},})expect(wrapper.html()).toBe(`<div> <h2> Heading </h2></div>`)})test('works with whitespace “condense”',()=>{constwrapper=mount(Component,{global: {config: {compilerOptions: {whitespace: 'condense',},},},})expect(wrapper.html()).toBe(`<div> <h2> Heading </h2></div>`)})
Describe the bug
During the upgrade process of a project to Vue 3 & Vue Test Utils 2, I’ve noticed a failing test that’s caused by a different whitespace setting used during test execution than what’s otherwise used in the project (via compiler options set in the project’s webpack configuration).
After trying to provide a minimal reproduction, it looks like setting
global.config.compilerOptions.whitespace
via amount
call’s options doesn’t always work. Specifically, setting it once (to any value) seems to prevent it being set to a different value in subsequentmount
calls.To Reproduce
Run the following test code in a project with
@vue/test-utils
installed. Both tests should pass, but the second will fail. Note also how changing the order of the tests makes it so that the test will fail that’s now the second even though it previously passed.Used Jest configuration:
Expected behavior
Related information:
@vue/test-utils
version: 2.0.0-rc.21Vue
version: nonenode
version: v16.15.0npm
(oryarn
) version: v8.10.0Additional context
I’ve tried avoiding this issue by globally setting this in a Jest setup file, but that didn’t help.
The text was updated successfully, but these errors were encountered: