Skip to content

docs: add typescript & angular usage section #10

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

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ yarn add --dev @testing-library/jasmine-dom

## Usage

### With JavaScript

You should have a directory for helpers specified inside the helpers array in your `jasmine.json` file.
Example:

Expand All @@ -122,7 +124,33 @@ beforeAll(() => {
});
```

That's it! You're good to go.
### With TypeScript

Add `"@testing-library/jasmine-dom"` to `types` in the tests `tsconfig` (e.g. `tsconfig.spec.json` in an Angular project).

Example:

```json
{
"compilerOptions": {
"types": [
"jasmine",
"node",
"@testing-library/jasmine-dom"
]
}
}
```

In your tests setup file, (`test.ts` in an Angular project) import jasmine-dom and add the matchers like so:

```typescript
import JasmineDOM from '@testing-library/jasmine-dom/dist';

beforeAll(() => {
jasmine.getEnv().addMatchers(JasmineDOM);
});
```

## Matchers

Expand Down