Module '"@angular/core/testing"' has no exported member 'DeferBlockState'.
matteoveraldi opened this issue ยท 12 comments
Hi,
I am unable to run a test with this library on a brand new angular project.
When I run npm run test the console report this error:
Error: node_modules/@testing-library/angular/src/lib/models.d.ts:2:28 - error TS2305: Module '"@angular/core/testing"' has no exported member 'DeferBlockState'.
2 import { ComponentFixture, DeferBlockState, TestBed } from '@angular/core/testing';
Info
Environment: Debian
Angular CLI version: 16.2.1
Testing library version: 14.5.0
test runner: karma
Do you have an example that's causing this?
I thought this wouldn't be a problem, but perhaps I'm missing something...
Fixed by rollback to previous minor version npm i -D @testing-library/angular@~14.4.1
@matteoveraldi I have bumped my project to the latest Angular.
I can confirm that it works in the following combination:
"name": "@angular/core",
"version": "17.0.4",
"name": "@testing-library/angular",
"version": "14.5.0",
It seems @testing-library/angular v14.5.0 has breaking changes for Angular v15.2.10
On Angular 16 it still fails
"name": "@angular/core",
"version": "16.2.12",
"name": "@testing-library/angular",
"version": "14.5.0",
Failed with:
Error: node_modules/@testing-library/angular/src/lib/models.d.ts:2:28 - error TS2305: Module '"@angular/core/testing"' has no exported member 'DeferBlockState'.
2 import { ComponentFixture, DeferBlockState, TestBed } from '@angular/core/testing';
~~~~~~~~~~~~~~~@optimistex are you importing DeferBlockState within your spec files?
@timdeschryver the problem is in the testing library source code: https://github.com/testing-library/angular-testing-library/blob/v14.5.0/projects/testing-library/src/lib/models.ts#L2
The compatibility matrix shows that v14.x is ok to use for angular v16.x, but testing library v14.5 uses several packages from angular v17, which feels like breaking back-compatibility, should those changes be moved to testing library v15?
Yea, @th3n3rd I'll probably do that later today.
I thought that the additional type wouldn't be a problem if it wasn't used in user's code (and this seems to be the case on a project that I'm working on ~ maybe because the usage of skipLibCheck).
Since it seems like it does have an impact I'll probably revert the change, and cut a v15 release.
This should be resolved, please let me know if it isn't.
v14.5.1: Angular 16
v15: Angular 17 (with deferrable view API)
It works now! Thank you @timdeschryver
I'm glad to hear that!
Thanks for bringing this to my attention, I'll close this issue ๐

