You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
24
25
@@ -27,8 +28,8 @@
27
28
When debugging component tests, it’s often necessary to inspect the DOM. The most common approach to do so is by using the good old `console.log` which has some downsides.
28
29
First of all, it’s annoying always to type
29
30
30
-
```
31
-
fixture.debugElement.nativeElement.innerHTML
31
+
```typescript
32
+
fixture.debugElement.nativeElement.innerHTML;
32
33
```
33
34
34
35
Moreover, the console.log statement doesn’t print the HTML in a very readable way. Therefore we still need to copy the string in a new HTML file and format it to be able to inspect it. Not with `@angular-extensions/pretty-html-log`
@@ -56,8 +57,8 @@ npm i -D @angular-extensions/pretty-html-log
56
57
This module is best used with Angular and Jest. Create a
57
58
`setupJest.ts` file in your `src` directory and add the following line **after your jest-preset-angular import. ⚠️ The order can matter**:
58
59
59
-
```
60
-
import '@angular-extensions/pretty-html-log'
60
+
```typescript
61
+
import'@angular-extensions/pretty-html-log';
61
62
```
62
63
63
64
This import adds a `logNgHTML` method to your console. You can then
@@ -88,10 +89,8 @@ The `console.logNgHTML()` method has the following signature:
88
89
89
90
In your test you can simply write the following line.
Currently, we support (DRACULA, VSCODE and MATERIAL). The themes can be importet from `pretty-html-log`, the
145
144
base library `@angular-extensions/pretty-html-log` depends on.
146
145
147
-
```
148
-
import {THEMES} from 'pretty-html-log';
146
+
```typescript
147
+
import {THEMES} from'pretty-html-log';
149
148
150
149
console.logNgHTML(fixture, false, THEMES.VSCODE);
151
150
```
151
+
152
+
# FAQ
153
+
154
+
I use the module but I don't get autocompletion when typing `console.logNgHTML`, furthermore I get the following error when I run my tests. `console.logNgHTML is not a function`. This is usually a sign that your `tsconfig.json` doesn't include the `setupJest.ts` file. Make sure that the `setupJest.ts` is included in your `tsconfig.json`.
0 commit comments