/
githubmirror
/
node
Обзор
Документация
Войти
/
githubmirror
/
node
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v22.23.2
test/sequential/test-process-warnings.js
36 строк
1 KB
Michaël Zasso
test: use `assert.match` instead of `regexp.test`
31 авг 2021, 19:50
Не верифицирован
31 авг 2021, 19:50
508890d
Код
Авторство
О чём код?
'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\)/); });