mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
test: add more coverage to node_config_file
PR-URL: https://github.com/nodejs/node/pull/57170 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Paolo Insogna <paolo@cowtech.it>
This commit is contained in:
1 parent
56773ba50d
commit
044d69a0af
5 files changed
+60
No files matched your search
+5
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"nodeOptions": {
|
||||
"inspect-port
|
||||
}
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
{
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"nodeOptions": "string"
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
[]
|
||||
@@ -254,3 +254,53 @@ test('should not allow users to sneak in a flag', async () => {
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
});
|
||||
|
||||
test('non object root', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-config-file',
|
||||
fixtures.path('rc/non-object-root.json'),
|
||||
'-p', '"Hello, World!"',
|
||||
]);
|
||||
match(result.stderr, /Root value unexpected not an object for/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
});
|
||||
|
||||
test('non object node options', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-config-file',
|
||||
fixtures.path('rc/non-object-node-options.json'),
|
||||
'-p', '"Hello, World!"',
|
||||
]);
|
||||
match(result.stderr, /"nodeOptions" value unexpected for/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
});
|
||||
|
||||
test('should throw correct error when a json is broken', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-config-file',
|
||||
fixtures.path('rc/broken.json'),
|
||||
'-p', '"Hello, World!"',
|
||||
]);
|
||||
match(result.stderr, /Can't parse/);
|
||||
match(result.stderr, /broken\.json: invalid content/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
});
|
||||
|
||||
test('broken value in node_options', async () => {
|
||||
const result = await spawnPromisified(process.execPath, [
|
||||
'--no-warnings',
|
||||
'--experimental-config-file',
|
||||
fixtures.path('rc/broken-node-options.json'),
|
||||
'-p', '"Hello, World!"',
|
||||
]);
|
||||
match(result.stderr, /Can't parse/);
|
||||
match(result.stderr, /broken-node-options\.json: invalid content/);
|
||||
strictEqual(result.stdout, '');
|
||||
strictEqual(result.code, 9);
|
||||
});
|
||||
Reference in new issue
Block a user