-
Notifications
You must be signed in to change notification settings - Fork 10
Open
DefinitelyTyped/DefinitelyTyped
#71300Labels
help wantedExtra attention is neededExtra attention is needed
Description
jasmine-domversion: 1.0.3nodeversion: 14.15.4npmversion: 6.14.10@angular/coreversion: 12.2.9typescriptversion: 4.3.2jasmine-coreversion: 3.8.0
Relevant code or config:
tsconfig.spec.json:
/* To learn more about this file see: https://angular.io/config/tsconfig. */
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/spec",
"types": ["jasmine", "@testing-library/jasmine-dom"]
},
"files": ["src/test.ts", "src/polyfills.ts"],
"include": ["src/**/*.spec.ts", "src/**/*.d.ts"]
}
test.ts:
// This file is required by karma.conf.js and loads recursively all the .spec and framework files
import 'zone.js/testing';
import { getTestBed } from '@angular/core/testing';
import {
BrowserDynamicTestingModule,
platformBrowserDynamicTesting,
} from '@angular/platform-browser-dynamic/testing';
import JasmineDOM from '@testing-library/jasmine-dom/dist';
declare const require: {
context(
path: string,
deep?: boolean,
filter?: RegExp
): {
keys(): string[];
<T>(id: string): T;
};
};
// First, initialize the Angular testing environment.
getTestBed().initTestEnvironment(BrowserDynamicTestingModule, platformBrowserDynamicTesting());
// Then we find all the tests.
const context = require.context('./', true, /\.spec\.ts$/);
// And load the modules.
context.keys().map(context);
beforeAll(() => {
// On the Jasmine version I'm using the addMatches method is directly on the jasmine variable instead of having to call .getEnv()
jasmine.addMatchers(JasmineDOM);
});What you did:
Tried to run the tests:
npm run-script test
After the error happened, installed the types package as suggested in the error message, but the same error occurred:
npm run-script testnpm i --save-dev @types/testing-library__jasmine-dom
What happened:
Error: src/test.ts:10:24 - error TS7016: Could not find a declaration file for module '@testing-library/jasmine-dom/dist'. 'C:/some-path/angular/node_modules/@testing-library
/jasmine-dom/dist/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/testing-library__jasmine-dom` if it exists or add a new declaration (.d.ts) file containing `declare module '@testing-library/jasmine-dom/dist';`
10 import JasmineDOM from '@testing-library/jasmine-dom/dist';
Problem description:
I couldn't make it work on an Angular 12 project by following the TypeScript instructions on the README file.
Please note that on tests.ts I had to call jasmine.addMatchers(JasmineDOM); without .getEnv() as it was suggested in the README. Anyway the error happens before this line.
I also took a look at this other related issue, but couldn't find anything that could solve this.
Is there any additional configuration I need to make this work?
Thanks in advance for the support and for providing this helpful library!
lundmikkel
Metadata
Metadata
Assignees
Labels
help wantedExtra attention is neededExtra attention is needed