Allow tests to pass without any test files (e.g. via Vitest `passWithNoTests`)

Aberta Para iniciantes
#33,055 1 comentário 3 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
2/5
Tempo estimado
1-3 horas
Facilidade para iniciantes
72/100
Tipo de issue
Funcionalidade
Clareza
Claramente especificada
Status de atividade
Pouca atividade
Stack de tecnologia
angular, typescript
Domínio
cli, testing

Direção de pesquisa

Comece por packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts, em torno das linhas 161-170, onde a verificação personalizada de ausência de arquivos de teste é descrita. Revise como o comando de teste passa as opções do runner para o Vitest e, em seguida, verifique se um projeto sem arquivos de teste é concluído com sucesso por meio da opção passWithNoTests do Vitest, enquanto o comportamento padrão permanece inalterado.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

area: @angular/cli gemini-triaged
Command

test

Description

Executing the test command on a project (app or lib) that does not have any test files (yet) will always lead to the following error message:

An exception occurred while getting runner-specific build options:
Error: No tests found matching the following patterns:
- Included: **/*.spec.ts, **/*.test.ts

Please check the 'test' target configuration in your project's 'angular.json' file.

However, many use cases exist where this behaviour is unintended. For example, a freshly generated project (even more so in a monorepo) will often start out without any real test cases defined, and it even may take some time for the first ones to be written. Even at this early point, though, I (as a developer) will usually want to already integrate test execution into a quality gate setup (like continuous integration).

Currently, the Angular CLI does not offer a way to allow the test command to succeed when no test files exist.

Related issue: https://github.com/nrwl/nx/issues/34241

Describe the solution you'd like

The most pragmatic solution would probably be:

Describe alternatives you've considered

Alternatively:

  • The Angular CLI test command could also expose its own option. This would however collide with the respective Vitest option and thus require conflict resolution / priority checks. Plus, skimming the source code leads me to believe that the Angular CLI is currently not actively loading any custom Vite config, just passing it on - so changes here would presumably affect multiple places.
Linguagem predominante
TypeScript
Estrelas
27k
Forks
11.8k
Merge médio
16h 21min
PRs com merge (30d)
170

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de angular/angular-cli

Todas as issues de angular/angular-cli

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.