'Class constructor FormControl cannot be invoked without 'new'
I have a simple Angular 13 repo where @ng-stack/forms
is used like
import { Component } from '@angular/core';
import { FormControl } from '@ng-stack/forms';
@Component({
selector: 'app-root',
})
export class AppComponent {
control = new FormControl<string>('');
}
When I run Jest test I got an error:
> [email protected] test
> jest --no-cache
FAIL src/app/app.component.spec.ts
AppComponent
× should create the app (54 ms)
● AppComponent › should create the app
TypeError: Class constructor FormControl cannot be invoked without 'new'
7 | })
8 | export class AppComponent {
> 9 | control = new FormControl<string>('');
| ^
10 | }
11 |
at new FormControl (node_modules/projects/forms/src/lib/form-control.ts:42:5)
at new AppComponent (src/app/app.component.ts:9:13)
at NodeInjectorFactory.AppComponent_Factory [as factory] (ng:\AppComponent\ɵfac.js:5:10)
at src/app/app.component.spec.ts:16:29
Test Suites: 1 failed, 1 total
Tests: 1 failed, 1 total
Snapshots: 0 total
Time: 5.825 s
Ran all test suites.
Can anyone explain where is this error coming from and how to fix it?
Solution 1:[1]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Eron Cardoso |