-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
44 lines (34 loc) · 1014 Bytes
/
test.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
42
43
44
'use strict'
const { test, after } = require('node:test')
const { deepStrictEqual, strictEqual } = require('node:assert')
const inspector = require('node:inspector')
const { connect } = require('./index.js')
inspector.open()
after(() => inspector.close())
test('connects and close (twice and close (twice))', async (t) => {
const client = await connect(inspector.url())
t.after(() => client.close())
await client.close()
})
test('evaluates', async (t) => {
const client = await connect(inspector.url())
t.after(() => client.close())
const result = await client.post('Runtime.evaluate', {
expression: '2 + 2',
returnByValue: true,
generatePreview: true
})
deepStrictEqual(result, {
result: {
description: '4',
type: 'number',
value: 4
}
})
const result2 = await client.post('Runtime.evaluate', {
expression: 'throw new Error("test")',
returnByValue: true,
generatePreview: true
})
strictEqual(result2.result.className, 'Error')
})