This repository has been archived by the owner on Aug 31, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
inspector: migrate to internal/errors
PR-URL: nodejs/node#15619 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ali Ijaz Sheikh <ofrobots@google.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
- Loading branch information
Showing
4 changed files
with
101 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
'use strict'; | ||
|
||
const common = require('../common'); | ||
|
||
common.skipIfInspectorDisabled(); | ||
|
||
const assert = require('assert'); | ||
const { Session } = require('inspector'); | ||
|
||
const session = new Session(); | ||
|
||
common.expectsError( | ||
() => session.post('Runtime.evaluate', { expression: '2 + 2' }), | ||
{ | ||
code: 'ERR_INSPECTOR_NOT_CONNECTED', | ||
type: Error, | ||
message: 'Session is not connected' | ||
} | ||
); | ||
|
||
assert.doesNotThrow(() => session.connect()); | ||
|
||
assert.doesNotThrow( | ||
() => session.post('Runtime.evaluate', { expression: '2 + 2' })); | ||
|
||
[1, {}, [], true, Infinity, undefined].forEach((i) => { | ||
common.expectsError( | ||
() => session.post(i), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: | ||
'The "method" argument must be of type string. ' + | ||
`Received type ${typeof i}` | ||
} | ||
); | ||
}); | ||
|
||
[1, true, Infinity].forEach((i) => { | ||
common.expectsError( | ||
() => session.post('test', i), | ||
{ | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
type: TypeError, | ||
message: | ||
'The "params" argument must be of type object. ' + | ||
`Received type ${typeof i}` | ||
} | ||
); | ||
}); | ||
|
||
common.expectsError( | ||
() => session.connect(), | ||
{ | ||
code: 'ERR_INSPECTOR_ALREADY_CONNECTED', | ||
type: Error, | ||
message: 'The inspector is already connected' | ||
} | ||
); | ||
|
||
assert.doesNotThrow(() => session.disconnect()); | ||
assert.doesNotThrow(() => session.disconnect()); |