GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: add more coverage to node_config_file · nodejs/node@5a21fa4

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • fixtures/rc
      • broken-node-options.json
      • broken.json
      • non-object-node-options.json
      • non-object-root.json
    • parallel
      • test-config-file.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/fixtures/rc/broken-node-options.json‎

Copy file name to clipboard
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"nodeOptions": {
3+
"inspect-port
4+
}
5+
}
Collapse file

‎test/fixtures/rc/broken.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{
Collapse file

‎test/fixtures/rc/non-object-node-options.json‎

Copy file name to clipboard
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"nodeOptions": "string"
3+
}
Collapse file

‎test/fixtures/rc/non-object-root.json‎

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
Collapse file

‎test/parallel/test-config-file.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-config-file.js
+50Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,3 +254,53 @@ test('should not allow users to sneak in a flag', async () => {
254254
strictEqual(result.stdout, '');
255255
strictEqual(result.code, 9);
256256
});
257+
258+
test('non object root', async () => {
259+
const result = await spawnPromisified(process.execPath, [
260+
'--no-warnings',
261+
'--experimental-config-file',
262+
fixtures.path('rc/non-object-root.json'),
263+
'-p', '"Hello, World!"',
264+
]);
265+
match(result.stderr, /Root value unexpected not an object for/);
266+
strictEqual(result.stdout, '');
267+
strictEqual(result.code, 9);
268+
});
269+
270+
test('non object node options', async () => {
271+
const result = await spawnPromisified(process.execPath, [
272+
'--no-warnings',
273+
'--experimental-config-file',
274+
fixtures.path('rc/non-object-node-options.json'),
275+
'-p', '"Hello, World!"',
276+
]);
277+
match(result.stderr, /"nodeOptions" value unexpected for/);
278+
strictEqual(result.stdout, '');
279+
strictEqual(result.code, 9);
280+
});
281+
282+
test('should throw correct error when a json is broken', async () => {
283+
const result = await spawnPromisified(process.execPath, [
284+
'--no-warnings',
285+
'--experimental-config-file',
286+
fixtures.path('rc/broken.json'),
287+
'-p', '"Hello, World!"',
288+
]);
289+
match(result.stderr, /Can't parse/);
290+
match(result.stderr, /broken\.json: invalid content/);
291+
strictEqual(result.stdout, '');
292+
strictEqual(result.code, 9);
293+
});
294+
295+
test('broken value in node_options', async () => {
296+
const result = await spawnPromisified(process.execPath, [
297+
'--no-warnings',
298+
'--experimental-config-file',
299+
fixtures.path('rc/broken-node-options.json'),
300+
'-p', '"Hello, World!"',
301+
]);
302+
match(result.stderr, /Can't parse/);
303+
match(result.stderr, /broken-node-options\.json: invalid content/);
304+
strictEqual(result.stdout, '');
305+
strictEqual(result.code, 9);
306+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.