|
1 | | -import {prettyDOM, logDOM} from '../pretty-dom' |
2 | | -import {getUserCodeFrame} from '../get-user-code-frame' |
| 1 | +import {prettyDOM} from '../pretty-dom' |
3 | 2 | import {render, renderIntoDocument} from './helpers/test-utils' |
4 | 3 |
|
5 | | -jest.mock('../get-user-code-frame') |
6 | | - |
7 | | -beforeEach(() => { |
8 | | - jest.spyOn(console, 'log').mockImplementation(() => {}) |
9 | | -}) |
10 | | - |
11 | | -afterEach(() => { |
12 | | - console.log.mockRestore() |
13 | | -}) |
14 | | - |
15 | 4 | test('prettyDOM prints out the given DOM element tree', () => { |
16 | 5 | const {container} = render('<div>Hello World!</div>') |
17 | 6 | expect(prettyDOM(container)).toMatchInlineSnapshot(` |
@@ -58,49 +47,6 @@ test('prettyDOM supports receiving the document element', () => { |
58 | 47 | `) |
59 | 48 | }) |
60 | 49 |
|
61 | | -test('logDOM logs prettyDOM to the console', () => { |
62 | | - const {container} = render('<div>Hello World!</div>') |
63 | | - logDOM(container) |
64 | | - expect(console.log).toHaveBeenCalledTimes(1) |
65 | | - expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(` |
66 | | - <div> |
67 | | - <div> |
68 | | - Hello World! |
69 | | - </div> |
70 | | - </div> |
71 | | - `) |
72 | | -}) |
73 | | - |
74 | | -test('logDOM logs prettyDOM with code frame to the console', () => { |
75 | | - getUserCodeFrame.mockImplementationOnce( |
76 | | - () => `"/home/john/projects/sample-error/error-example.js:7:14 |
77 | | - 5 | document.createTextNode('Hello World!') |
78 | | - 6 | ) |
79 | | - > 7 | screen.debug() |
80 | | - | ^ |
81 | | - " |
82 | | - `, |
83 | | - ) |
84 | | - const {container} = render('<div>Hello World!</div>') |
85 | | - logDOM(container) |
86 | | - expect(console.log).toHaveBeenCalledTimes(1) |
87 | | - expect(console.log.mock.calls[0][0]).toMatchInlineSnapshot(` |
88 | | - <div> |
89 | | - <div> |
90 | | - Hello World! |
91 | | - </div> |
92 | | - </div> |
93 | | -
|
94 | | - "/home/john/projects/sample-error/error-example.js:7:14 |
95 | | - 5 | document.createTextNode('Hello World!') |
96 | | - 6 | ) |
97 | | - > 7 | screen.debug() |
98 | | - | ^ |
99 | | - " |
100 | | - |
101 | | - `) |
102 | | -}) |
103 | | - |
104 | 50 | describe('prettyDOM fails with first parameter without outerHTML field', () => { |
105 | 51 | test('with array', () => { |
106 | 52 | expect(() => prettyDOM(['outerHTML'])).toThrowErrorMatchingInlineSnapshot( |
|
0 commit comments