angular / angular/angular-cli

alternatives to change TestBed configurations without creating the test.ts files

Open
#24,345 6 comments 5 reactions 0 assignees View on GitHub
area: @angular-devkit/build-angular devkit/build-angular:karma feature feature: insufficient votes
Dominant language
TypeScript
Stars
27k
Forks
11.8k
Avg merge
14h 23m
Merged PRs (30d)
162

Description

### Which @angular/* package(s) are relevant/related to the feature request?

core

### Description

with Angular 15, now the `test.ts` file doesn't get generated by default, so it's not an easy task to change the `TestBed` configurations for example to enable `errorOnUnknownElements`
it will also be nice if we can change the pattern of the tests

### Proposed solution

to add the configurations inside the `angular.json` files in the options section of test

something like

```
"options": {
"polyfills": [
"zone.js",
"zone.js/testing"
],
"tsConfig": "tsconfig.spec.json",
"inlineStyleLanguage": "scss",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"src/styles.scss"
],
"scripts": [],
"errorOnUnknownElements": true, <---
"errorOnUnknownProperties": true, <---
"pattern": "\.custom-spec\.ts$" <---
}
```

### Alternatives considered

to be able to enable them globally from any script (to create a js file and add it to the scripts of the test) with something like

```
getTestBed().setoptions({
errorOnUnknownElements: true,
errorOnUnknownProperties: true,
pattern: /\.custom-spec\.ts$/
});
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing how angular.json test options are handled and how the test.ts bootstrap is generated or replaced. Use the requested TestBed settings and custom test pattern as the acceptance cases; done means projects can configure them without creating test.ts files.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
testing, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.