Skip to content
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

Issue when running tests: "Generic type 'ɵɵComponentDeclaration' requires between 7 and 8 type arguments." #348

Closed
arhill05 opened this issue Dec 16, 2022 · 3 comments · Fixed by #349

Comments

@arhill05
Copy link

Attempting to run my tests with ng test and I immediately get an error upon importing from '@angular/testing-library'

The code in question:

import { render } from "@testing-library/angular";

The error in full:

Error: node_modules/@testing-library/angular/src/lib/testing-library.d.ts:10:18 - error TS2707: Generic type 'ɵɵComponentDeclaration' requires between 7 and 8 type arguments.

10     static ɵcmp: i0.ɵɵComponentDeclaration<WrapperComponent, "atl-wrapper-component", never, {}, {}, never, never, false, never>;

Removing the import from my test allows the build to pass.

package.json contents:

{
  "name": "...",
  "version": "0.0.0",
  "scripts": {
    ...
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^14.2.0",
    "@angular/cdk": "~14.2.6",
    "@angular/common": "^14.2.0",
    "@angular/compiler": "^14.2.0",
    "@angular/core": "^14.2.0",
    "@angular/forms": "^14.2.0",
    "@angular/material": "~14.2.6",
    "@angular/platform-browser": "^14.2.0",
    "@angular/platform-browser-dynamic": "^14.2.0",
    "@angular/router": "^14.2.0",
    ...
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^14.2.3",
    "@angular/cli": "~14.2.3",
    "@angular/compiler-cli": "^14.2.0",
    "@testing-library/angular": "^13.0.1",
    "@types/jasmine": "~4.0.0",
    "eslint-config-prettier": "^8.5.0",
    "husky": "^8.0.2",
    "jasmine-core": "~4.3.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "karma-sonarqube-reporter": "^1.4.0",
    "lint-staged": "^13.1.0",
    "prettier": "^2.8.1",
    "typescript": "~4.7.2"
  },
}
@timdeschryver
Copy link
Member

Thanks for opening this issue @arhill05 .
I have to test this out, I suspect that this happens because of a conflicted Angular version.
Have you tried this on Angular v15?

@arhill05
Copy link
Author

I have not tried it on Angular 15, but I don't think we are ready to move to the latest version yet unfortunately.

I did just try this using version 12.3.0 of the @testing-library/angular package and it seems to work without issue.

@timdeschryver
Copy link
Member

@arhill05 I tested this out, and the peer dependency was wrong.
v13 of Testing Library is required to have a dependency to Angular v15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants