From 242ffb648392896f620d643c5a1418048360c82a Mon Sep 17 00:00:00 2001 From: David Goss Date: Fri, 6 Oct 2023 18:03:57 +0100 Subject: [PATCH] make the logging nicer and reference the doc --- src/configuration/split_format_descriptor.ts | 5 ++- .../split_format_descriptor_spec.ts | 41 ++++++++++--------- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/configuration/split_format_descriptor.ts b/src/configuration/split_format_descriptor.ts index 10fc805e5..eefdb7efa 100644 --- a/src/configuration/split_format_descriptor.ts +++ b/src/configuration/split_format_descriptor.ts @@ -9,7 +9,10 @@ export function splitFormatDescriptor( if (result[1]) { expected += `:"${result[1]}"` } - logger.warn(`Should be ${expected}`) + logger.warn( + `Each part of a user-specified format should be quoted; see https://github.com/cucumber/cucumber-js/blob/main/docs/deprecations.md#ambiguous-colons-in-formats +Change to ${expected}` + ) } let result: string[] let match1, match2 diff --git a/src/configuration/split_format_descriptor_spec.ts b/src/configuration/split_format_descriptor_spec.ts index 1d956025a..e447ddc80 100644 --- a/src/configuration/split_format_descriptor_spec.ts +++ b/src/configuration/split_format_descriptor_spec.ts @@ -25,7 +25,7 @@ describe('splitFormatDescriptor', () => { input: 'file:///custom/formatter:file:///formatter/output.txt', output: ['file:///custom/formatter', 'file:///formatter/output.txt'], warning: - 'Should be "file:///custom/formatter":"file:///formatter/output.txt"', + 'Change to "file:///custom/formatter":"file:///formatter/output.txt"', }, { description: 'splits file URLs for UNC path', @@ -36,7 +36,7 @@ describe('splitFormatDescriptor', () => { 'file://hostname/formatter/output.txt', ], warning: - 'Should be "file://hostname/custom/formatter":"file://hostname/formatter/output.txt"', + 'Change to "file://hostname/custom/formatter":"file://hostname/formatter/output.txt"', }, { description: 'splits file URLs for absolute windows path', @@ -46,7 +46,7 @@ describe('splitFormatDescriptor', () => { 'file://C:\\formatter\\output.txt', ], warning: - 'Should be "file://C:\\custom\\formatter":"file://C:\\formatter\\output.txt"', + 'Change to "file://C:\\custom\\formatter":"file://C:\\formatter\\output.txt"', }, { description: @@ -57,7 +57,7 @@ describe('splitFormatDescriptor', () => { 'file:///C:/formatter/output.txt', ], warning: - 'Should be "file:///C:/custom/formatter":"file:///C:/formatter/output.txt"', + 'Change to "file:///C:/custom/formatter":"file:///C:/formatter/output.txt"', }, { description: 'splits valid file URLs for absolute windows path', @@ -67,7 +67,7 @@ describe('splitFormatDescriptor', () => { 'file:///C:\\formatter\\output.txt', ], warning: - 'Should be "file:///C:\\custom\\formatter":"file:///C:\\formatter\\output.txt"', + 'Change to "file:///C:\\custom\\formatter":"file:///C:\\formatter\\output.txt"', }, { description: @@ -78,7 +78,7 @@ describe('splitFormatDescriptor', () => { 'file:///C:/formatter/output.txt', ], warning: - 'Should be "file:///C:/custom/formatter":"file:///C:/formatter/output.txt"', + 'Change to "file:///C:/custom/formatter":"file:///C:/formatter/output.txt"', }, { description: 'splits absolute unix paths', @@ -89,14 +89,14 @@ describe('splitFormatDescriptor', () => { description: 'splits absolute windows paths', input: 'C:\\custom\\formatter:C:\\formatter\\output.txt', output: ['C:\\custom\\formatter', 'C:\\formatter\\output.txt'], - warning: 'Should be "C:\\custom\\formatter":"C:\\formatter\\output.txt"', + warning: 'Change to "C:\\custom\\formatter":"C:\\formatter\\output.txt"', }, { description: 'splits absolute windows paths with "/" as directory separator', input: 'C:/custom/formatter:C:/formatter/output.txt', output: ['C:/custom/formatter', 'C:/formatter/output.txt'], - warning: 'Should be "C:/custom/formatter":"C:/formatter/output.txt"', + warning: 'Change to "C:/custom/formatter":"C:/formatter/output.txt"', }, { description: 'splits UNC paths', @@ -125,56 +125,56 @@ describe('splitFormatDescriptor', () => { 'does not split a single file URL for absolute unix path, adds empty string', input: 'file:///custom/formatter', output: ['file:///custom/formatter', ''], - warning: 'Should be "file:///custom/formatter"', + warning: 'Change to "file:///custom/formatter"', }, { description: 'does not split a single file URL for UNC path, adds empty string', input: 'file://hostname/custom/formatter', output: ['file://hostname/custom/formatter', ''], - warning: 'Should be "file://hostname/custom/formatter"', + warning: 'Change to "file://hostname/custom/formatter"', }, { description: 'does not split a single file URL for absolute windows path, adds empty string', input: 'file://C:\\custom\\formatter', output: ['file://C:\\custom\\formatter', ''], - warning: 'Should be "file://C:\\custom\\formatter"', + warning: 'Change to "file://C:\\custom\\formatter"', }, { description: 'does not split a single file URL for absolute windows path with "/" as directory separator, adds empty string', input: 'file://C:/custom/formatter', output: ['file://C:/custom/formatter', ''], - warning: 'Should be "file://C:/custom/formatter"', + warning: 'Change to "file://C:/custom/formatter"', }, { description: 'does not split a valid single file URL for absolute windows path, adds empty string', input: 'file:///C:\\custom\\formatter', output: ['file:///C:\\custom\\formatter', ''], - warning: 'Should be "file:///C:\\custom\\formatter"', + warning: 'Change to "file:///C:\\custom\\formatter"', }, { description: 'does not split a valid single file URL for absolute windows path with "/" as directory separator, adds empty string', input: 'file:///C:/custom/formatter', output: ['file:///C:/custom/formatter', ''], - warning: 'Should be "file:///C:/custom/formatter"', + warning: 'Change to "file:///C:/custom/formatter"', }, { description: 'does not split a single absolute windows path, adds empty string', input: 'C:\\custom\\formatter', output: ['C:\\custom\\formatter', ''], - warning: 'Should be "C:\\custom\\formatter"', + warning: 'Change to "C:\\custom\\formatter"', }, { description: 'does not split a single absolute windows path with "/" as directory separator, adds empty string', input: 'C:/custom/formatter', output: ['C:/custom/formatter', ''], - warning: 'Should be "C:/custom/formatter"', + warning: 'Change to "C:/custom/formatter"', }, { description: 'does not split quoted values: case 1', @@ -185,13 +185,13 @@ describe('splitFormatDescriptor', () => { description: 'does not split quoted values: case 2', input: '"foo:bar":baz:qux', output: ['foo:bar', 'baz:qux'], - warning: 'Should be "foo:bar":"baz:qux"', + warning: 'Change to "foo:bar":"baz:qux"', }, { description: 'does not split quoted values: case 3', input: 'foo:bar:"baz:qux"', output: ['foo:bar', 'baz:qux'], - warning: 'Should be "foo:bar":"baz:qux"', + warning: 'Change to "foo:bar":"baz:qux"', }, { description: 'does not split quoted values: case 4', @@ -202,7 +202,7 @@ describe('splitFormatDescriptor', () => { description: 'splits string contains multiple ":"', input: 'foo:bar:baz:qux', output: ['foo', 'bar:baz:qux'], - warning: 'Should be "foo":"bar:baz:qux"', + warning: 'Change to "foo":"bar:baz:qux"', }, ] @@ -211,7 +211,8 @@ describe('splitFormatDescriptor', () => { const logger = new FakeLogger() expect(splitFormatDescriptor(logger, input)).to.eql(output) if (warning) { - expect(logger.warn).to.have.been.calledWith(warning) + expect(logger.warn).to.have.been.called() + expect(logger.warn.firstCall.firstArg as string).to.contain(warning) } else { expect(logger.warn).not.to.have.been.called() }