-
Notifications
You must be signed in to change notification settings - Fork 111
/
Copy pathdebug.js
41 lines (32 loc) · 1.07 KB
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import {render} from '@testing-library/vue'
import HelloWorld from './components/HelloWorld'
beforeEach(() => {
jest.spyOn(console, 'log').mockImplementation(() => {})
})
afterEach(() => {
console.log.mockRestore()
})
test('debug pretty prints the container if no parameter is provided', () => {
const {debug} = render(HelloWorld)
debug()
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Hello World'),
)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Lorem ipsum dolor sit amet'),
)
})
test('debug pretty prints the provided parameter', () => {
const {getByText, debug} = render(HelloWorld)
// debug accepts a DOM node as a parameter.
debug(getByText('Lorem ipsum dolor sit amet'))
expect(console.log).toHaveBeenCalledTimes(1)
expect(console.log).toHaveBeenCalledWith(
expect.stringContaining('Lorem ipsum dolor sit amet'),
)
// Notice the 'not' particle
expect(console.log).not.toHaveBeenCalledWith(
expect.stringContaining('Hello World'),
)
})