Skip to content

Commit 2443072

Browse files
authored
docs: add typescript & angular usage section (#10)
1 parent 8e61829 commit 2443072

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,8 @@ yarn add --dev @testing-library/jasmine-dom
9999

100100
## Usage
101101

102+
### With JavaScript
103+
102104
You should have a directory for helpers specified inside the helpers array in your `jasmine.json` file.
103105
Example:
104106

@@ -122,7 +124,33 @@ beforeAll(() => {
122124
});
123125
```
124126

125-
That's it! You're good to go.
127+
### With TypeScript
128+
129+
Add `"@testing-library/jasmine-dom"` to `types` in the tests `tsconfig` (e.g. `tsconfig.spec.json` in an Angular project).
130+
131+
Example:
132+
133+
```json
134+
{
135+
"compilerOptions": {
136+
"types": [
137+
"jasmine",
138+
"node",
139+
"@testing-library/jasmine-dom"
140+
]
141+
}
142+
}
143+
```
144+
145+
In your tests setup file, (`test.ts` in an Angular project) import jasmine-dom and add the matchers like so:
146+
147+
```typescript
148+
import JasmineDOM from '@testing-library/jasmine-dom/dist';
149+
150+
beforeAll(() => {
151+
jasmine.getEnv().addMatchers(JasmineDOM);
152+
});
153+
```
126154

127155
## Matchers
128156

0 commit comments

Comments
 (0)