Skip to content

SFC styles are not being applied to component in test environment with VTL #438

Open
@joaopslins

Description

@joaopslins

Repository with reproduction: https://github.com/joaopslins/vue-sfc-styles-issue-repro

I'm using Vue 2 with Vue Testing Library

Using toBeVisible() matcher against an element with display: none; applied via a class in <styles> section does not work in my test. Since I couldn't find other people with the same issue (except this SO question where the author solved the issue by other means), I guess this is some configuration issue, or I must be doing something wrong.

I wasn't sure in which repo I should open this issue but I think VTL is working properly, so it must be something related to vue-jest. Unless I'm mistaken, I think vue-jest should apply the styles correctly, due to https://github.com/vuejs/vue-jest#supported-style-languages.

Component:
https://github.com/joaopslins/vue-sfc-styles-issue-repro/blob/8d1ac53921dcbe75d81eb3327d07ad9d650344d6/src/HelloWorld.vue#L1-L9

Test:
https://github.com/joaopslins/vue-sfc-styles-issue-repro/blob/8d1ac53921dcbe75d81eb3327d07ad9d650344d6/src/__tests__/HelloWorld.spec.js#L1-L13

This CodeSandbox makes me think it is possible though: https://codesandbox.io/s/vue-testing-sample-input-forked-drjsm?file=/src/components/Button.test.js

Relevant versions:
Node: 14
"jest": "^27.4.7",
"vue": "^2.6.11"
"@vue/vue2-jest": "^27.0.0-alpha.4",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions