Skip to content

fix(@schematics/angular): do not generate tsconfig.spec.json when tests are skipped - #34482

Closed
thekhegay wants to merge 1 commit into
angular:mainfrom
thekhegay:skip-tests-spec-tsconfig
Closed

thekhegay wants to merge 1 commit into
angular:mainfrom
thekhegay:skip-tests-spec-tsconfig

Conversation

@thekhegay

Copy link
Copy Markdown
Contributor

PR Checklist

PR Type

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: #9160

I start apps with ng new --skip-tests and first thing after is deleting tsconfig.spec.json by hand
On 22.2.3 ng new st --skip-tests still creates st/tsconfig.spec.json with vitest/globals types, while angular.json has only build and serve and vitest is not in package.json
Filter for tsconfig.spec.json.template in application/index.ts checks only minimal, other test bits there (test target, spec project reference, test dependencies, schematic defaults) already check skipTests || minimal

What is the new behavior?

tsconfig.spec.json is filtered out with skipTests too, same shape as #32550
ng new --skip-tests and ng g app --skip-tests no longer create it

New case in application/index_spec.ts fails on main

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Commit says Refs #9160 since issue is not fully covered: root package.json still gets "test": "ng test" from workspace schematic, which knows only minimal
That needs new skipTests option on workspace passed from ng-new, can add it here or in seperate PR if you want
Library schematic has no skipTests option, so nothing changes there

…ts are skipped

with `skipTests` application schematic already leaves out test target, spec reference in root `tsconfig.json`, test runner dependencies and spec files, yet it still wrote `tsconfig.spec.json` that no target or tsconfig refrences
file is now filtered out for `skipTests` same way as for `minimal`, so `ng new --skip-tests` and `ng g app --skip-tests` no longer leave it behind
`"test": "ng test"` script in workspace `package.json` is still added, workspace schematic has no `skipTests` option

Refs angular#9160

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the Angular application schematic to prevent the creation of tsconfig.spec.json when the skipTests option is enabled, in addition to when the minimal option is set. It also adds a corresponding unit test to verify this behavior. I have no feedback to provide as there are no review comments.

@alan-agius4

Copy link
Copy Markdown
Collaborator

This is actually working as intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants