When I run tests on my project to render the component, an error occurs:
Error: testing.TestBed.inject is not a function
This is the code for the test component:
import { Component, Input } from "@angular/core";
@Component({
selector: 'counter',
template: `
<button (click)="decrement()">-</button>
<span data-testid="count">Current Count: {{ counter }}</span>
<button (click)="increment()">+</button>
`,
})
export class CounterComponent {
@Input() counter = 0
increment() {
this.counter += 1
}
decrement() {
this.counter -= 1
}
}
Here is the testing library code for Angular:
import {render, screen } from '@testing-library/angular'
import {CounterComponent} from './prueba.component'
describe('Counter', () => {
test('should render counter', async () => {
await render(CounterComponent, {
componentProperties: {counter: 5},
})
expect(screen.getByText('Current Count: 5')).toBeTruthy();
})
})