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

Offen Anfängerfreundlich
#33,055 1 Kommentar 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
72/100
Issue-Typ
Feature
Klarheit
Klar beschrieben
Aktivitätsstatus
Ruhig
Tech-Stack
angular, typescript
Bereich
cli, testing

Rechercherichtung

Beginne mit packages/angular/build/src/builders/unit-test/runners/vitest/build-options.ts bei den Zeilen 161-170, wo die benutzerdefinierte Prüfung auf keine Testdateien beschrieben wird. Überprüfe, wie der Testbefehl Runner-Optionen an Vitest übergibt, und verifiziere anschließend, dass ein Projekt ohne Testdateien mit Vitest's passWithNoTests-Option erfolgreich ist, während das Standardverhalten unverändert bleibt.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.
Vorherrschende Sprache
TypeScript
Sterne
27k
Forks
11.8k
Ø Merge
16 Std. 21 Min.
Gemergte PRs (30 T.)
170

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus angular/angular-cli

Alle Issues in angular/angular-cli

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.