@@ -17,8 +17,7 @@ jest.mock('fs', () => ({
17
17
) ,
18
18
} ) )
19
19
20
- const userStackFrame =
21
- 'at somethingWrong (/home/john/projects/sample-error/error-example.js:7:14)'
20
+ const userStackFrame = 'at somethingWrong (/sample-error/error-example.js:7:14)'
22
21
23
22
let globalErrorMock
24
23
@@ -31,16 +30,16 @@ afterEach(() => {
31
30
global . Error . mockRestore ( )
32
31
} )
33
32
34
- test ( 'it returns only client code frame when code frames from node_modules are first' , ( ) => {
33
+ test ( 'it returns only user code frame when code frames from node_modules are first' , ( ) => {
35
34
const stack = `Error: Kaboom
36
- at Object.<anonymous> (/home/john/projects/projects/ sample-error/node_modules/@es2050/console/build/index.js:4:10)
35
+ at Object.<anonymous> (/sample-error/node_modules/@es2050/console/build/index.js:4:10)
37
36
${ userStackFrame }
38
37
`
39
38
globalErrorMock . mockImplementationOnce ( ( ) => ( { stack} ) )
40
39
const userTrace = getUserCodeFrame ( stack )
41
40
42
41
expect ( userTrace ) . toMatchInlineSnapshot ( `
43
- "/home/john/projects/ sample-error/error-example.js:7:14
42
+ "/sample-error/error-example.js:7:14
44
43
5 | document.createTextNode('Hello world')
45
44
6 | )
46
45
> 7 | screen.debug()
@@ -49,18 +48,18 @@ test('it returns only client code frame when code frames from node_modules are f
49
48
` )
50
49
} )
51
50
52
- test ( 'it returns only client code frame when node code frames are present afterwards' , ( ) => {
51
+ test ( 'it returns only user code frame when node code frames are present afterwards' , ( ) => {
53
52
const stack = `Error: Kaboom
54
- at Object.<anonymous> (/home/john/projects/projects/ sample-error/node_modules/@es2050/console/build/index.js:4:10)
53
+ at Object.<anonymous> (/sample-error/node_modules/@es2050/console/build/index.js:4:10)
55
54
${ userStackFrame }
56
- at Object.<anonymous> (/home/user/Documents/projects/ sample-error/error-example.js:14:1)
55
+ at Object.<anonymous> (/sample-error/error-example.js:14:1)
57
56
at internal/main/run_main_module.js:17:47
58
57
`
59
58
globalErrorMock . mockImplementationOnce ( ( ) => ( { stack} ) )
60
59
const userTrace = getUserCodeFrame ( )
61
60
62
61
expect ( userTrace ) . toMatchInlineSnapshot ( `
63
- "/home/john/projects/ sample-error/error-example.js:7:14
62
+ "/sample-error/error-example.js:7:14
64
63
5 | document.createTextNode('Hello world')
65
64
6 | )
66
65
> 7 | screen.debug()
@@ -86,6 +85,6 @@ test("it returns empty string if file from code frame can't be read", () => {
86
85
expect ( getUserCodeFrame ( stack ) ) . toEqual ( '' )
87
86
expect ( consoleWarnSpy ) . toHaveBeenCalledTimes ( 1 )
88
87
expect ( consoleWarnSpy ) . toHaveBeenCalledWith (
89
- `Couldn't read file /home/john/projects/ sample-error/error-example.js for displaying the code frame` ,
88
+ `Couldn't read file /sample-error/error-example.js for displaying the code frame` ,
90
89
)
91
90
} )
0 commit comments