-
-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: MockBuilder failing with error after updating Angular version 12 to 14. #3274
Comments
Hi @mdv27, thanks for the report. Please provide a repo which fails the error. |
If it's easier you can upload an archive with the project and node_modules right here in your comment. |
@satanTime Created repo from scratch and it does fail with same error. Let me know if more details are required. |
Thanks! checking it! |
So, the problem comes from |
That's so quick! 😮 👏 May I know how did you find the root cause? |
Basically I removed everything from your component, the test was failing, then I started to remove module by module and found out this dependency. The final test is: import {MockBuilder, MockRender} from 'ng-mocks';
import {TestBed} from "@angular/core/testing";
import {NgModule} from '@angular/core';
import {InputsModule} from '@progress/kendo-angular-inputs';
import {Component} from '@angular/core';
@Component({
selector: 'app-header',
template: '',
})
class HeaderComponent {}
@NgModule({
declarations: [HeaderComponent],
imports: [
InputsModule,
],
})
class AppModule {}
describe('HeaderComponent', () => {
describe('ng-mocks', () => {
beforeEach(() => MockBuilder(HeaderComponent, AppModule));
it('should create component', () => {
const fixture = MockRender(HeaderComponent, {});
const component = fixture.point.componentInstance;
expect(component).toBeDefined();
});
});
describe('TestBed', () => {
beforeEach(() => {
return TestBed.configureTestingModule({
imports: [AppModule],
}).compileComponents();
});
it('should create component', () => {
const fixture = TestBed.createComponent(HeaderComponent);
fixture.detectChanges();
const component = fixture.componentInstance;
expect(component).toBeDefined();
});
});
}); |
Ideally if module/dependency is mocked/stubbed, test should not trigger/run the dependency code, I assume this is not honored with |
I think there is a problem how the mock of a dependency has been defined, so when Angular is creating a TestBed env, it stumbles over it. |
So. Some of declarations of Now |
fix(core): generates compatible function names #3274
v14.1.3 has been released and contains a fix for the issue. Feel free to reopen the issue or to submit a new one if you meet any problems. |
This change is working for me. Thank you @satanTime 👏 |
Description of the bug
Unit tests are failing with below error when Angular version is updated to 14.x.x from 12.x.x.
Dependency list:
Line of code where getting below error:
Error stack:
An example of the bug
Above error stack.
Link:
Expected vs actual behavior
Test should run without error.
The text was updated successfully, but these errors were encountered: