Skip to content

Commit

Permalink
moar testing
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore committed Jan 7, 2025
1 parent 0a67c2e commit 520a432
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions test/logger.loglevel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,71 @@ test('Setting log level to "error" only logs error (and above)', t => {
'Error messages should be logged at error level'
);
});

test('Test all log levels', t => {
configureLog({ level: 'trace' });
const logger = getLogger('test-all-levels');

const traceOutput = captureConsole('trace', () => {
logger.trace('Should log at trace level');
});

const debugOutput = captureConsole('debug', () => {
logger.debug('Should log at debug level');
});

const verboseOutput = captureConsole('verbose', () => {
logger.verbose('Should log at verbose level');
});

const infoOutput = captureConsole('info', () => {
logger.info('Should log at info level');
});

const warningOutput = captureConsole('warning', () => {
logger.warning('Should log at warning level');
});

const errorOutput = captureConsole('error', () => {
logger.error('Should log at error level');
});

const criticalOutput = captureConsole('critical', () => {
logger.critical('Should log at critical level');
});

t.true(
traceOutput.includes('Should log at trace level'),
'Trace messages should be logged at trace level'
);

t.true(
debugOutput.includes('Should log at debug level'),
'Debug messages should be logged at trace level'
);

t.true(
verboseOutput.includes('Should log at verbose level'),
'Verbose messages should be logged at trace level'
);

t.true(
infoOutput.includes('Should log at info level'),
'Info messages should be logged at trace level'
);

t.true(
warningOutput.includes('Should log at warning level'),
'Warning messages should be logged at trace level'
);

t.true(
errorOutput.includes('Should log at error level'),
'Error messages should be logged at trace level'
);

t.true(
criticalOutput.includes('Should log at critical level'),
'Critical messages should be logged at trace level'
);
});

0 comments on commit 520a432

Please # to comment.