custom-event.js
This file
Path
test/verbose/custom-event.js
58 lines · 4.1 KiB · JavaScript
Last changed by
TweaksSindre Sorhusbefore adoption698a1b8
History of this fileTake it
TweaksSindre Sorhusbefore adoption698a1b8
lines 1–2why, one step back1import assert from 'node:assert/strict';2import test from 'node:test';Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 3–7why, one step back3import {setFixtureDirectory} from '../helpers/fixtures-directory.js';4import {runVerboseSubprocess} from '../helpers/verbose.js';56setFixtureDirectory();7TweaksSindre Sorhusbefore adoption698a1b8
line 8why, one step back8const testVerboseType = async (type, isSync) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 9why, one step back9 const {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'type'});TweaksSindre Sorhusbefore adoption698a1b8
line 10why, one step back10 assert.equal(stderr, type);Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 11–12why, one step back11};12TweaksSindre Sorhusbefore adoption698a1b8
lines 13–21why, one step back13test('"verbose" function receives verboseObject.type "command"', () => testVerboseType('command', false));14test('"verbose" function receives verboseObject.type "output"', () => testVerboseType('output', false));15test('"verbose" function receives verboseObject.type "ipc"', () => testVerboseType('ipc', false));16test('"verbose" function receives verboseObject.type "error"', () => testVerboseType('error', false));17test('"verbose" function receives verboseObject.type "duration"', () => testVerboseType('duration', false));18test('"verbose" function receives verboseObject.type "command", sync', () => testVerboseType('command', true));19test('"verbose" function receives verboseObject.type "output", sync', () => testVerboseType('output', true));20test('"verbose" function receives verboseObject.type "error", sync', () => testVerboseType('error', true));21test('"verbose" function receives verboseObject.type "duration", sync', () => testVerboseType('duration', true));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 22why, one step back22TweaksSindre Sorhusbefore adoption698a1b8
line 23why, one step back23const testVerboseTimestamp = async (type, isSync) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 24why, one step back24 const {stderr} = await runVerboseSubprocess({isSync, type, eventProperty: 'timestamp'});TweaksSindre Sorhusbefore adoption698a1b8
line 25why, one step back25 assert.ok(Number.isInteger(new Date(stderr).getTime()));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 26–27why, one step back26};27TweaksSindre Sorhusbefore adoption698a1b8
lines 28–36why, one step back28test('"verbose" function receives verboseObject.timestamp, "command"', () => testVerboseTimestamp('command', false));29test('"verbose" function receives verboseObject.timestamp, "output"', () => testVerboseTimestamp('output', false));30test('"verbose" function receives verboseObject.timestamp, "ipc"', () => testVerboseTimestamp('ipc', false));31test('"verbose" function receives verboseObject.timestamp, "error"', () => testVerboseTimestamp('error', false));32test('"verbose" function receives verboseObject.timestamp, "duration"', () => testVerboseTimestamp('duration', false));33test('"verbose" function receives verboseObject.timestamp, "command", sync', () => testVerboseTimestamp('command', true));34test('"verbose" function receives verboseObject.timestamp, "output", sync', () => testVerboseTimestamp('output', true));35test('"verbose" function receives verboseObject.timestamp, "error", sync', () => testVerboseTimestamp('error', true));36test('"verbose" function receives verboseObject.timestamp, "duration", sync', () => testVerboseTimestamp('duration', true));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
line 37why, one step back37TweaksSindre Sorhusbefore adoption698a1b8
line 38why, one step back38const testVerbosePiped = async (type, isSync, expectedOutputs) => {Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 39–46why, one step back39 const {stderr} = await runVerboseSubprocess({40 isSync,41 type,42 parentFixture: 'nested-pipe-verbose.js',43 destinationFile: 'noop-verbose.js',44 destinationArguments: ['. . .'],45 eventProperty: 'piped',46 });TweaksSindre Sorhusbefore adoption698a1b8
line 47why, one step back47 assert.ok(expectedOutputs.map(expectedOutput => expectedOutput.join('\n')).includes(stderr));Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348
lines 48–49why, one step back48};49TweaksSindre Sorhusbefore adoption698a1b8
lines 50–58why, one step back50test('"verbose" function receives verboseObject.piped, "command"', () => testVerbosePiped('command', false, [[false, true]]));51test('"verbose" function receives verboseObject.piped, "output"', () => testVerbosePiped('output', false, [[true]]));52test('"verbose" function receives verboseObject.piped, "ipc"', () => testVerbosePiped('ipc', false, [[false, true], [true, false]]));53test('"verbose" function receives verboseObject.piped, "error"', () => testVerbosePiped('error', false, [[false, true], [true, false]]));54test('"verbose" function receives verboseObject.piped, "duration"', () => testVerbosePiped('duration', false, [[false, true], [true, false]]));55test('"verbose" function receives verboseObject.piped, "command", sync', () => testVerbosePiped('command', true, [[false, true]]));56test('"verbose" function receives verboseObject.piped, "output", sync', () => testVerbosePiped('output', true, [[true]]));57test('"verbose" function receives verboseObject.piped, "error", sync', () => testVerbosePiped('error', true, [[false, true], [true, false]]));58test('"verbose" function receives verboseObject.piped, "duration", sync', () => testVerbosePiped('duration', true, [[false, true], [true, false]]));