Skip to content

Commit 0abd3d0

Browse files
committed
chore: fix string assertion in tests
1 parent bbeec8d commit 0abd3d0

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

packages/logger/tests/unit/formatters.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,7 @@ describe('Formatters', () => {
334334
error: new Error('Something went wrong'),
335335
name: 'Error',
336336
expectedFields: {
337+
location: expect.any(String),
337338
message: 'Something went wrong',
338339
cause: undefined,
339340
},
@@ -342,6 +343,7 @@ describe('Formatters', () => {
342343
error: new ReferenceError('doesNotExist is not defined'),
343344
name: 'ReferenceError',
344345
expectedFields: {
346+
location: expect.any(String),
345347
message: 'doesNotExist is not defined',
346348
cause: undefined,
347349
},
@@ -370,6 +372,7 @@ describe('Formatters', () => {
370372
error: new RangeError('The argument must be between 10 and 20'),
371373
name: 'RangeError',
372374
expectedFields: {
375+
location: expect.any(String),
373376
message: 'The argument must be between 10 and 20',
374377
cause: undefined,
375378
},
@@ -378,6 +381,7 @@ describe('Formatters', () => {
378381
error: new ReferenceError('foo is not defined'),
379382
name: 'ReferenceError',
380383
expectedFields: {
384+
location: expect.any(String),
381385
message: 'foo is not defined',
382386
cause: undefined,
383387
},
@@ -386,6 +390,7 @@ describe('Formatters', () => {
386390
error: new SyntaxError(`Unexpected identifier 'bar'`),
387391
name: 'SyntaxError',
388392
expectedFields: {
393+
location: expect.any(String),
389394
message: `Unexpected identifier 'bar'`,
390395
cause: undefined,
391396
},
@@ -394,6 +399,7 @@ describe('Formatters', () => {
394399
error: new TypeError(`Cannot read property 'foo' of null`),
395400
name: 'TypeError',
396401
expectedFields: {
402+
location: expect.any(String),
397403
message: expect.stringMatching(/Cannot read property/),
398404
cause: undefined,
399405
},
@@ -402,6 +408,7 @@ describe('Formatters', () => {
402408
error: new URIError('URI malformed'),
403409
name: 'URIError',
404410
expectedFields: {
411+
location: expect.any(String),
405412
message: 'URI malformed',
406413
cause: undefined,
407414
},
@@ -410,9 +417,10 @@ describe('Formatters', () => {
410417
error: new ErrorWithCause('foo', { cause: new Error('bar') }),
411418
name: 'ErrorWithCause',
412419
expectedFields: {
420+
location: expect.any(String),
413421
message: 'foo',
414422
cause: {
415-
location: expect.stringMatching(fileNameRegexp),
423+
location: expect.any(String),
416424
message: 'bar',
417425
name: 'Error',
418426
stack: expect.stringMatching(fileNameRegexpWithLine),
@@ -423,6 +431,7 @@ describe('Formatters', () => {
423431
error: new ErrorWithCauseString('foo', { cause: 'bar' }),
424432
name: 'ErrorWithCauseString',
425433
expectedFields: {
434+
location: expect.any(String),
426435
message: 'foo',
427436
cause: 'bar',
428437
},
@@ -435,7 +444,6 @@ describe('Formatters', () => {
435444

436445
// Assess
437446
expect(formattedError).toEqual({
438-
location: expect.stringMatching(fileNameRegexp),
439447
stack: expect.stringMatching(fileNameRegexpWithLine),
440448
name,
441449
...expectedFields,
@@ -479,7 +487,7 @@ describe('Formatters', () => {
479487

480488
// Assess
481489
expect(formattedError).toEqual({
482-
location: expect.stringMatching(fileNameRegexp),
490+
location: expect.any(String),
483491
stack: expect.stringMatching(fileNameRegexpWithLine),
484492
name: 'SuperCustomError',
485493
message: 'Something went wrong',

0 commit comments

Comments
 (0)