Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Wrapper.Text function is trimming elements #2251

Closed
occitaneUbald opened this issue Nov 21, 2023 · 4 comments
Closed

Bug: Wrapper.Text function is trimming elements #2251

occitaneUbald opened this issue Nov 21, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@occitaneUbald
Copy link

Describe the bug
Text function is trimming elements when multiple elements are concatenated

To Reproduce
This example works in 2.4.1 but does not work in 2.4.2

it('does not work', () => {
    const wrapper = shallowMount({
        template: `<span>Trimmed </span><span>Example</span>`
    })

    expect(wrapper.text()).toBe('Trimmed Example')
})

Expected behavior
This test should pass as in 2.4.1 version

@occitaneUbald occitaneUbald added the bug Something isn't working label Nov 21, 2023
@cexbrayat
Copy link
Member

Hi @occitaneUbald

This is because of this fix in VTU #2231
But I think the new behavior is probably better.

You'll have to update your test to either:

  • check with TrimmedExample
  • check both span elements individually withelement.textContent if you want to check if the space is there (because text() does trim the content).

@occitaneUbald
Copy link
Author

You should at least mention this in your changelog as it is a breaking change in your API

@cexbrayat
Copy link
Member

Maybe we should have, but I don't think it was spotted by the contributor who did this fix.

Feel free to open a PR to open the changelog, we'll gladly review it.

@occitaneUbald
Copy link
Author

And we should probably add an automated test to avoid further undetected regressions in the future on this API

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants