Using Jasmine-DOM in Angular project

243 views Asked by At

I have an Angular 10 CLI project (v10.1.2). I've installed @testing-library/[email protected], and I want the nice matchers like .toBeInTheDocument(), but as I'm using Karma to run Jasmine (configured via Angular) and Typescript, I'm not sure how to install the @testing-library/jasmine-dom matchers?

I tried following the instructions for the latest version (v1.1.0), but while I can see the matchers on the HTMLMatchers type in VSCode, I can't actually add the Matchers. Trying to import them with import JasmineDOM from '@testing-library/jasmine-dom'; gives an error File C:/.../node_modules/@types/testing-library__jasmine-dom/index.d.ts is not a module.

As this is an Angular CLI project, with Jasmine behind Karma, would it actually make more sense to use a Karma plugin? (I can't see any...)

1

There are 1 answers

0
Ian Grainger On BEST ANSWER

I halped the dev of jasmine-dom to fix a bug with the CSS library which was preventing my using it with Karma and we've updated the docs - so this should be pretty straightforward, now!