Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

407
Visualizações
What is the intended test structure of vitest inside Vue projects?

I created a new Vue project via npm init vue@latest ( with vitest ). Inside ./src/components is a __test__ directory containing a component unit test.

Is it intended to create another __test__ directory for the ./src/views directory if you want to test your view files?

So when using a folder by type structure ( you might also want to use a folder by feature structure ) the project might look like

src
├── components
│   ├── MyComponent.vue
│   └── __test__
│       └── MyComponent.spec.vue
└── views
    ├── MyView1.vue
    ├── MyView2.vue
    └── __test__
        ├── MyView1.spec.vue
        └── MyView2.spec.vue

Please don't get me wrong, this is not a question about personal preferences . I just would like to know how vitest wants me to do it.

Because when having a __test__ directory right next to my code, why wouldn't you put the spec files right next to the code and get rid of the directory?

E.g.

src
├── components
│   ├── MyComponent.vue
│   └── MyComponent.spec.vue
└── views
    ├── MyView1.vue
    ├── MyView1.spec.vue
    ├── MyView2.vue
    └── MyView2.spec.vue

It would be nice if one could explain the "common" way of using vitest inside Vue projects because until now I added a test directory right next to the src directory and mirrored the structure but it seems vitest/Vue prefers a different approach.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda