|
15 | 15 | - [Getting started](#getting-started)
|
16 | 16 | - [Installation](#installation)
|
17 | 17 | - [Usage with an import](#usage-with-an-import)
|
18 |
| - - [Provide phl as a Jest global](#provide-phl-as-a-jest-global) |
19 | 18 | - [API](#api)
|
20 | 19 | - [Examples](#examples)
|
21 | 20 | - [Pass in specific DebugElement](#pass-in-specific-debugelement)
|
@@ -75,42 +74,6 @@ describe('my test suite', () => {
|
75 | 74 |
|
76 | 75 | > Note that this way adds a import method. To make sure this import statement gets cleaned up we should configure our eslint to clean up unused imports. More: https://www.npmjs.com/package/eslint-plugin-unused-imports.
|
77 | 76 |
|
78 |
| -### Provide phl as a Jest global |
79 |
| - |
80 |
| -Maybe you don't want to use a plugin that cleans up unused imports or maybe this import statement just annoys you. If that's the case, you have to option to provide the `phl` method as a Jest global. Similar to `it`, `describe` or `expect`. |
81 |
| - |
82 |
| -1. rename you jest config from `jest.config.js` to `jest.config.mjs`. Using the `.mjs` extension allows us to use ES Modules inside our Jest config. Jest officially supports `.mjs` configuration files. |
83 |
| - |
84 |
| -2. Import `phl` from `@angular-extensions/pretty-html-log` and provide it as a global inside your `jest.config.mjs`: |
85 |
| - |
86 |
| - ```javascript |
87 |
| - import { phl } from '@angular-extensions/pretty-html-log'; |
88 |
| - |
89 |
| - module.exports = { |
90 |
| - globals: { |
91 |
| - phl |
92 |
| - } |
93 |
| - }; |
94 |
| - ``` |
95 |
| - |
96 |
| -3. Import `@angular-extensions/pretty-html-log` inside your jest.setup.ts |
97 |
| - |
98 |
| - ```typescript |
99 |
| - import 'jest-preset-angular/setup-jest'; |
100 |
| - import '@angular-extensions/pretty-html-log'; |
101 |
| - ``` |
102 |
| - |
103 |
| -4. Start using it inside your tests without the usage of import 🤩 |
104 |
| - |
105 |
| - ```typescript |
106 |
| - describe('my test suite', () => { |
107 |
| - it('should be green', () => { |
108 |
| - phl(fixture); // This will pretty print the fixture |
109 |
| - expect(myTable.getRows()).toBe(5); |
110 |
| - }); |
111 |
| - }); |
112 |
| - ``` |
113 |
| - |
114 | 77 | ## API
|
115 | 78 |
|
116 | 79 | The `phl` method has the following signature:
|
|
0 commit comments