fix: Test error classes correctly

This commit is contained in:
Joachim Van Herwegen
2021-01-28 17:16:11 +01:00
parent a57105be8e
commit c29928c32c
18 changed files with 110 additions and 78 deletions

View File

@@ -12,7 +12,7 @@ describe('LazyLogger', (): void => {
it('throws when no logger factory is set in the lazy logger factory.', async(): Promise<void> => {
expect((): any => logger.log('debug', 'my message', { abc: true }))
.toThrow(new Error('No logger factory has been set. Can be caused by logger invocation during initialization.'));
.toThrow('No logger factory has been set. Can be caused by logger invocation during initialization.');
});
it('creates a new logger using the factory.', async(): Promise<void> => {

View File

@@ -31,7 +31,7 @@ describe('LazyLoggerFactory', (): void => {
it('throws when retrieving the inner factory if none has been set.', async(): Promise<void> => {
expect((): any => LazyLoggerFactory.getInstance().loggerFactory)
.toThrow(new Error('No logger factory has been set. Can be caused by logger invocation during initialization.'));
.toThrow('No logger factory has been set. Can be caused by logger invocation during initialization.');
});
it('Returns the inner factory if one has been set.', async(): Promise<void> => {
@@ -60,6 +60,6 @@ describe('LazyLoggerFactory', (): void => {
it('errors on invoking LazyLoggers if a factory has not been set yet.', async(): Promise<void> => {
const logger = LazyLoggerFactory.getInstance().createLogger('MyLabel');
expect((): any => logger.log('debug', 'my message', { abc: true }))
.toThrow(new Error('No logger factory has been set. Can be caused by logger invocation during initialization.'));
.toThrow('No logger factory has been set. Can be caused by logger invocation during initialization.');
});
});

View File

@@ -28,6 +28,6 @@ describe('LogUtil', (): void => {
setGlobalLoggerFactory(new VoidLoggerFactory());
resetGlobalLoggerFactory();
expect((): any => LazyLoggerFactory.getInstance().loggerFactory)
.toThrow(new Error('No logger factory has been set. Can be caused by logger invocation during initialization.'));
.toThrow('No logger factory has been set. Can be caused by logger invocation during initialization.');
});
});