karma-runner / karma-runner/karma
Unit Test Error in Angular 13 -- TypeError: jit___pipeBind1_8(...) is not a function
- Dominant language
- JavaScript
- Stars
- 12k
- Forks
- 1.7k
- PR merge metrics
- No merged PRs in 30d
Description
### Expected behaviour
I am trying to test a component but keep running into a cryptic message on the test suite. I believe it might be related to an issue with detecting a pipe in my component, but I wanted to ask the community.
Below is my spec:
```
describe('MyComponent', () => {
let component: MyComponent;
let fixture: ComponentFixture;
let methodSpy: jasmine.Spy;
const eventSubject = new ReplaySubject(1);
const routerMock = {
navigate: jasmine.createSpy('navigate'),
events: eventSubject.asObservable(),
url: 'test/url'
};
beforeEach(async () => {
await TestBed.configureTestingModule({
schemas: [CUSTOM_ELEMENTS_SCHEMA],
imports: [RouterTestingModule, HttpClientTestingModule],
providers: [
{provide: Router, useValue: routerMock},
MyComponentFacadeService,
OtherRestService,
provideMockStore()],
declarations: [ MyComponent]
})
.compileComponents();
});
beforeEach(() => {
fixture = TestBed.createComponent(MyComponent);
component = fixture.componentInstance;
methodSpy = spyOn(component, 'methodWithPipe');
});
afterEach(() => {
fixture.destroy();
});
it('should create', () => {
fixture.detectChanges();
expect(component).toBeTruthy();
});
});
```
### Actual behaviour
Here is the error I am running into with logs:
```
[MyComponent](http://localhost:9876/?spec=MyComponent) > [should create](http://localhost:9876/?spec=MyComponent%20should%20create)
TypeError: jit___pipeBind1_8(...) is not a function
` at templateFn (ng:///MyComponent.js:95:56)
at executeTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9618:9)
at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9484:13)
at refreshComponent (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:10660:13)
at refreshChildComponents (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9280:9)
at refreshView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9534:13)
at renderComponentOrTemplate (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:9598:9)
at tickRootContext (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:10834:9)
at detectChangesInRootView (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:10859:5)
at RootViewRef.detectChanges (http://localhost:9876/_karma_webpack_/webpack:/node_modules/@angular/core/fesm2015/core.mjs:21471:9)`
```
### Environment Details
- Karma version (output of `karma --version`):
6.3.17
- Relevant part of your `karma.config.js` file
```
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
```
Contributor guide
Assessment
This issue has not been assessed yet.