summaryrefslogtreecommitdiff
path: root/test/sequential/test-process-warnings.js
blob: f4457e137ec08c539dfb4c354c9931d40a048070 (plain)
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
'use strict';

require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const execFile = require('child_process').execFile;
const warnmod = require.resolve(fixtures.path('warnings.js'));
const node = process.execPath;

const normal = [warnmod];
const noWarn = ['--no-warnings', warnmod];
const traceWarn = ['--trace-warnings', warnmod];

const warningMessage = /^\(.+\)\sWarning: a bad practice warning/;

execFile(node, normal, function(er, stdout, stderr) {
  // Show Process Warnings
  assert.strictEqual(er, null);
  assert.strictEqual(stdout, '');
  assert.match(stderr, warningMessage);
});

execFile(node, noWarn, function(er, stdout, stderr) {
  // Hide Process Warnings
  assert.strictEqual(er, null);
  assert.strictEqual(stdout, '');
  assert.doesNotMatch(stderr, warningMessage);
});

execFile(node, traceWarn, function(er, stdout, stderr) {
  // Show Warning Trace
  assert.strictEqual(er, null);
  assert.strictEqual(stdout, '');
  assert.match(stderr, warningMessage);
  assert.match(stderr, /at Object\.<anonymous>\s\(.+warnings\.js:3:9\)/);
});