diff --git a/common/changes/@microsoft/rush/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@microsoft/rush/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..bd7ff97cb34 --- /dev/null +++ b/common/changes/@microsoft/rush/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@microsoft/rush", + "comment": "", + "type": "none" + } + ], + "packageName": "@microsoft/rush" +} \ No newline at end of file diff --git a/common/changes/@rushstack/heft-config-file/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@rushstack/heft-config-file/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..9b24a4fdcca --- /dev/null +++ b/common/changes/@rushstack/heft-config-file/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/heft-config-file", + "comment": "", + "type": "none" + } + ], + "packageName": "@rushstack/heft-config-file" +} \ No newline at end of file diff --git a/common/changes/@rushstack/localization-utilities/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@rushstack/localization-utilities/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..3830d7f42e0 --- /dev/null +++ b/common/changes/@rushstack/localization-utilities/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/localization-utilities", + "comment": "", + "type": "none" + } + ], + "packageName": "@rushstack/localization-utilities" +} \ No newline at end of file diff --git a/common/changes/@rushstack/operation-graph/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@rushstack/operation-graph/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..eabefe94ed8 --- /dev/null +++ b/common/changes/@rushstack/operation-graph/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/operation-graph", + "comment": "", + "type": "none" + } + ], + "packageName": "@rushstack/operation-graph" +} \ No newline at end of file diff --git a/common/changes/@rushstack/terminal/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@rushstack/terminal/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..0f01aaf8b42 --- /dev/null +++ b/common/changes/@rushstack/terminal/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/terminal", + "comment": "Add a `getAllOutput` function to `StringBufferTerminalProvider` that returns an object containing all output severities.", + "type": "minor" + } + ], + "packageName": "@rushstack/terminal" +} \ No newline at end of file diff --git a/common/changes/@rushstack/typings-generator/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json b/common/changes/@rushstack/typings-generator/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json new file mode 100644 index 00000000000..8f04a7afc26 --- /dev/null +++ b/common/changes/@rushstack/typings-generator/StringBufferTerminalProvider-snapshot-ergonomics_2025-12-29-21-12.json @@ -0,0 +1,10 @@ +{ + "changes": [ + { + "packageName": "@rushstack/typings-generator", + "comment": "", + "type": "none" + } + ], + "packageName": "@rushstack/typings-generator" +} \ No newline at end of file diff --git a/common/reviews/api/terminal.api.md b/common/reviews/api/terminal.api.md index cd5edfb7e06..419a4c1c2f7 100644 --- a/common/reviews/api/terminal.api.md +++ b/common/reviews/api/terminal.api.md @@ -105,6 +105,20 @@ export class DiscardStdoutTransform extends TerminalTransform { protected onWriteChunk(chunk: ITerminalChunk): void; } +// @beta (undocumented) +export interface IAllStringBufferOutput { + // (undocumented) + debug: string; + // (undocumented) + error: string; + // (undocumented) + log: string; + // (undocumented) + verbose: string; + // (undocumented) + warning: string; +} + // @public export interface IAnsiEscapeConvertForTestsOptions { encodeNewlines?: boolean; @@ -364,6 +378,9 @@ export class StdioWritable extends TerminalWritable { export class StringBufferTerminalProvider implements ITerminalProvider { constructor(supportsColor?: boolean); get eolCharacter(): string; + getAllOutput(sparse?: false, options?: IStringBufferOutputOptions): IAllStringBufferOutput; + // (undocumented) + getAllOutput(sparse: true, options?: IStringBufferOutputOptions): Partial; getDebugOutput(options?: IStringBufferOutputOptions): string; getErrorOutput(options?: IStringBufferOutputOptions): string; getOutput(options?: IStringBufferOutputOptions): string; @@ -371,7 +388,7 @@ export class StringBufferTerminalProvider implements ITerminalProvider { getVerbose(options?: IStringBufferOutputOptions): string; getVerboseOutput(options?: IStringBufferOutputOptions): string; getWarningOutput(options?: IStringBufferOutputOptions): string; - get supportsColor(): boolean; + readonly supportsColor: boolean; write(data: string, severity: TerminalProviderSeverity): void; } diff --git a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts index 2afb977e9e7..27bb1965dcd 100644 --- a/libraries/heft-config-file/src/test/ConfigurationFile.test.ts +++ b/libraries/heft-config-file/src/test/ConfigurationFile.test.ts @@ -26,13 +26,7 @@ describe('ConfigurationFile', () => { }); afterEach(() => { - expect({ - log: terminalProvider.getOutput(), - warning: terminalProvider.getWarningOutput(), - error: terminalProvider.getErrorOutput(), - verbose: terminalProvider.getVerboseOutput(), - debug: terminalProvider.getDebugOutput() - }).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); }); describe('A simple config file', () => { diff --git a/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap b/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap index 04cdb9dff85..a9fe0cb92b6 100644 --- a/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap +++ b/libraries/heft-config-file/src/test/__snapshots__/ConfigurationFile.test.ts.snap @@ -1,544 +1,128 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ConfigurationFile A complex config file Can get the original $schema property value 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A complex config file Can get the original $schema property value 1`] = `Object {}`; -exports[`ConfigurationFile A complex config file Correctly loads a complex config file (Deprecated PathResolutionMethod.NodeResolve) 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A complex config file Correctly loads a complex config file (Deprecated PathResolutionMethod.NodeResolve) 1`] = `Object {}`; -exports[`ConfigurationFile A complex config file Correctly loads a complex config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A complex config file Correctly loads a complex config file 1`] = `Object {}`; -exports[`ConfigurationFile A complex config file Correctly loads a complex config file async (Deprecated PathResolutionMethod.NodeResolve) 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A complex config file Correctly loads a complex config file async (Deprecated PathResolutionMethod.NodeResolve) 1`] = `Object {}`; -exports[`ConfigurationFile A complex config file Correctly loads a complex config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A complex config file Correctly loads a complex config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly loads the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly loads the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly loads the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly loads the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the project root 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the project root 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the project root async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file containing an array and an object Correctly resolves paths relative to the project root async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "append" and "merge" in config meta 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "append" and "merge" in config meta 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "append" and "merge" in config meta async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "append" and "merge" in config meta async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "custom" in config meta 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "custom" in config meta 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "custom" in config meta async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "custom" in config meta async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "replace" in config meta 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "replace" in config meta 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "replace" in config meta async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with "replace" in config meta async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with default config meta 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with default config meta 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with default config meta async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with default config meta async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with modified merge behaviors for arrays and objects 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with modified merge behaviors for arrays and objects 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with modified merge behaviors for arrays and objects async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly loads the config file with modified merge behaviors for arrays and objects async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly resolves paths relative to the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly resolves paths relative to the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with "extends" Correctly resolves paths relative to the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with "extends" Correctly resolves paths relative to the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly loads the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly loads the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly loads the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly loads the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the project root 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the project root 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the project root async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object Correctly resolves paths relative to the project root async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object The NonProjectConfigurationFile version works correctly 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object The NonProjectConfigurationFile version works correctly 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema object The NonProjectConfigurationFile version works correctly async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema object The NonProjectConfigurationFile version works correctly async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly loads the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly loads the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly loads the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly loads the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the config file 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the config file 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the config file async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the config file async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the project root 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the project root 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the project root async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path Correctly resolves paths relative to the project root async 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path The NonProjectConfigurationFile version works correctly 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path The NonProjectConfigurationFile version works correctly 1`] = `Object {}`; -exports[`ConfigurationFile A simple config file with a JSON schema path The NonProjectConfigurationFile version works correctly async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile A simple config file with a JSON schema path The NonProjectConfigurationFile version works correctly async 1`] = `Object {}`; -exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with a single inheritance type annotation 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with a single inheritance type annotation 1`] = `Object {}`; -exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with inheritance type annotations 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with inheritance type annotations 1`] = `Object {}`; -exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with inheritance type annotations async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations Correctly loads a complex config file with inheritance type annotations async 1`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type 1`] = `"Issue in processing configuration file property \\"c\\". Property is not an array, but the inheritance type is set as \\"append\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type async 1`] = `"Issue in processing configuration file property \\"c\\". Property is not an array, but the inheritance type is set as \\"append\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a keyed object uses the 'append' inheritance type async 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type 1`] = `"Issue in processing configuration file property \\"$l.inheritanceType\\". An inheritance type was provided for a property that is not a keyed object or array."`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type async 1`] = `"Issue in processing configuration file property \\"$l.inheritanceType\\". An inheritance type was provided for a property that is not a keyed object or array."`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when a non-object property uses an inheritance type async 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type 1`] = `"Issue in processing configuration file property \\"a\\". Property is not a keyed object, but the inheritance type is set as \\"merge\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type async 1`] = `"Issue in processing configuration file property \\"a\\". Property is not a keyed object, but the inheritance type is set as \\"merge\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an array uses the 'merge' inheritance type async 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property 1`] = `"Issue in processing configuration file property \\"$c.inheritanceType\\". An inheritance type was provided but no matching property was found in the parent."`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property async 1`] = `"Issue in processing configuration file property \\"$c.inheritanceType\\". An inheritance type was provided but no matching property was found in the parent."`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an inheritance type is specified for an unspecified property async 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified 1`] = `"Issue in processing configuration file property \\"$a.inheritanceType\\". An unsupported inheritance type was provided: \\"custom\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified 2`] = `Object {}`; exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified async 1`] = `"Issue in processing configuration file property \\"$a.inheritanceType\\". An unsupported inheritance type was provided: \\"custom\\""`; -exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile a complex file with inheritance type annotations throws an error when an unsupported inheritance type is specified async 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema 1`] = ` "Resolved configuration object does not match schema: Error: JSON validation failed: @@ -548,15 +132,7 @@ Error: #/filePaths must be array" `; -exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema async 1`] = ` "Resolved configuration object does not match schema: Error: JSON validation failed: @@ -566,15 +142,7 @@ Error: #/filePaths must be array" `; -exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error for a file that doesn't match its schema async 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema 1`] = ` "Resolved configuration object does not match schema: Error: JSON validation failed: @@ -588,15 +156,7 @@ Error: # must match exactly one schema in oneOf" `; -exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema async 1`] = ` "Resolved configuration object does not match schema: Error: JSON validation failed: @@ -610,25 +170,13 @@ Error: # must match exactly one schema in oneOf" `; -exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when a combined config file doesn't match the schema async 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error when a requested file doesn't exist 1`] = `"File does not exist: /lib/test/errorCases/folderThatDoesntExist/config.json"`; exports[`ConfigurationFile error cases Throws an error when a requested file doesn't exist 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/folderThatDoesntExist/config.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -637,10 +185,6 @@ exports[`ConfigurationFile error cases Throws an error when a requested file doe exports[`ConfigurationFile error cases Throws an error when a requested file doesn't exist async 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/folderThatDoesntExist/config.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -649,10 +193,6 @@ exports[`ConfigurationFile error cases Throws an error when an "extends" propert exports[`ConfigurationFile error cases Throws an error when an "extends" property points to a file that cannot be resolved 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/extendsNotExist/config2.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -661,74 +201,30 @@ exports[`ConfigurationFile error cases Throws an error when an "extends" propert exports[`ConfigurationFile error cases Throws an error when an "extends" property points to a file that cannot be resolved async 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/extendsNotExist/config2.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; -exports[`ConfigurationFile error cases Throws an error when the file isn't valid JSON 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when the file isn't valid JSON 1`] = `Object {}`; -exports[`ConfigurationFile error cases Throws an error when the file isn't valid JSON async 1`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when the file isn't valid JSON async 1`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties 1`] = `"A loop has been detected in the \\"extends\\" properties of configuration file at \\"/lib/test/errorCases/circularReference/config1.json\\"."`; -exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties 2`] = `Object {}`; exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties async 1`] = `"A loop has been detected in the \\"extends\\" properties of configuration file at \\"/lib/test/errorCases/circularReference/config1.json\\"."`; -exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties async 2`] = ` -Object { - "debug": "", - "error": "", - "log": "", - "verbose": "", - "warning": "", -} -`; +exports[`ConfigurationFile error cases Throws an error when there is a circular reference in "extends" properties async 2`] = `Object {}`; exports[`ConfigurationFile error cases returns undefined when the file doesn't exist for tryLoadConfigurationFileForProject 1`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/invalidType/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; exports[`ConfigurationFile error cases returns undefined when the file doesn't exist for tryLoadConfigurationFileForProjectAsync 1`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/invalidType/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -737,10 +233,6 @@ exports[`ConfigurationFile error cases throws an error when the file doesn't exi exports[`ConfigurationFile error cases throws an error when the file doesn't exist 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/invalidType/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -749,50 +241,30 @@ exports[`ConfigurationFile error cases throws an error when the file doesn't exi exports[`ConfigurationFile error cases throws an error when the file doesn't exist async 2`] = ` Object { "debug": "Configuration file \\"/lib/test/errorCases/invalidType/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; exports[`ConfigurationFile loading a rig correctly loads a config file inside a rig 1`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/simplestConfigFile.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; exports[`ConfigurationFile loading a rig correctly loads a config file inside a rig async 1`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/simplestConfigFile.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; exports[`ConfigurationFile loading a rig correctly loads a config file inside a rig via tryLoadConfigurationFileForProject 1`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/simplestConfigFile.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; exports[`ConfigurationFile loading a rig correctly loads a config file inside a rig via tryLoadConfigurationFileForProjectAsync 1`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/simplestConfigFile.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -801,10 +273,6 @@ exports[`ConfigurationFile loading a rig throws an error when a config file does exports[`ConfigurationFile loading a rig throws an error when a config file doesn't exist in a project referencing a rig, which also doesn't have the file 2`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/notExist.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]Configuration file \\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default/config/notExist.json\\" not found.[n]Configuration file \\"/lib/test/project-referencing-rig/config/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; @@ -813,9 +281,5 @@ exports[`ConfigurationFile loading a rig throws an error when a config file does exports[`ConfigurationFile loading a rig throws an error when a config file doesn't exist in a project referencing a rig, which also doesn't have the file async 2`] = ` Object { "debug": "Configuration file \\"/lib/test/project-referencing-rig/config/notExist.json\\" does not exist. Attempting to load via rig (\\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default\\").[n]Configuration file \\"/lib/test/project-referencing-rig/node_modules/test-rig/profiles/default/config/notExist.json\\" not found.[n]Configuration file \\"/lib/test/project-referencing-rig/config/notExist.json\\" not found.[n]", - "error": "", - "log": "", - "verbose": "", - "warning": "", } `; diff --git a/libraries/localization-utilities/src/parsers/test/__snapshots__/parseResx.test.ts.snap b/libraries/localization-utilities/src/parsers/test/__snapshots__/parseResx.test.ts.snap index 477b13c81b5..aa6e30030b1 100644 --- a/libraries/localization-utilities/src/parsers/test/__snapshots__/parseResx.test.ts.snap +++ b/libraries/localization-utilities/src/parsers/test/__snapshots__/parseResx.test.ts.snap @@ -35,7 +35,7 @@ Object { exports[`parseResx fails to parse a RESX file with a duplicate string: terminal output 1`] = ` Object { - "errorOutput": "test.resx(6,45): Duplicate string value \\"stringA\\"[n]", + "error": "test.resx(6,45): Duplicate string value \\"stringA\\"[n]", } `; @@ -50,7 +50,7 @@ Object { exports[`parseResx ignoreMissingResxComments when set to false, warns on a missing comment: terminal output 1`] = ` Object { - "warningOutput": "test.resx(3,59): Missing string comment in element[n]", + "warning": "test.resx(3,59): Missing string comment in element[n]", } `; @@ -113,7 +113,7 @@ Object { exports[`parseResx prints an error on invalid XML: terminal output 1`] = ` Object { - "errorOutput": "test.resx(3,41): Found unexpected non-empty text node in RESX element[n]", + "error": "test.resx(3,41): Found unexpected non-empty text node in RESX element[n]", } `; diff --git a/libraries/localization-utilities/src/parsers/test/parseResx.test.ts b/libraries/localization-utilities/src/parsers/test/parseResx.test.ts index bc914847d18..2fdb4403986 100644 --- a/libraries/localization-utilities/src/parsers/test/parseResx.test.ts +++ b/libraries/localization-utilities/src/parsers/test/parseResx.test.ts @@ -16,34 +16,7 @@ describe(parseResx.name, () => { }); afterEach(() => { - const outputObject: Record = {}; - - const output: string = terminalProvider.getOutput(); - if (output) { - outputObject.output = output; - } - - const verboseOutput: string = terminalProvider.getVerboseOutput(); - if (verboseOutput) { - outputObject.verboseOutput = verboseOutput; - } - - const errorOutput: string = terminalProvider.getErrorOutput(); - if (errorOutput) { - outputObject.errorOutput = errorOutput; - } - - const warningOutput: string = terminalProvider.getWarningOutput(); - if (warningOutput) { - outputObject.warningOutput = warningOutput; - } - - const debugOutput: string = terminalProvider.getDebugOutput(); - if (debugOutput) { - outputObject.debugOutput = debugOutput; - } - - expect(outputObject).toMatchSnapshot('terminal output'); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot('terminal output'); }); async function testResxAsync( diff --git a/libraries/operation-graph/src/test/OperationExecutionManager.test.ts b/libraries/operation-graph/src/test/OperationExecutionManager.test.ts index f1649986914..f0233cbe010 100644 --- a/libraries/operation-graph/src/test/OperationExecutionManager.test.ts +++ b/libraries/operation-graph/src/test/OperationExecutionManager.test.ts @@ -68,7 +68,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.NoOp); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); }); it('handles trivial input', async () => { @@ -87,7 +87,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.Success); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(operation.state?.status).toBe(OperationStatus.NoOp); }); @@ -135,7 +135,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.Success); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(runAlpha).toHaveBeenCalledTimes(1); expect(runBeta).toHaveBeenCalledTimes(1); @@ -187,7 +187,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.Failure); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(runAlpha).toHaveBeenCalledTimes(1); expect(runBeta).toHaveBeenCalledTimes(0); @@ -218,7 +218,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.NoOp); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); }); it('respects priority order', async () => { @@ -271,7 +271,7 @@ describe(OperationExecutionManager.name, () => { expect(executed).toEqual([beta, alpha]); expect(result).toBe(OperationStatus.Success); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(runAlpha).toHaveBeenCalledTimes(1); expect(runBeta).toHaveBeenCalledTimes(1); @@ -324,7 +324,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result).toBe(OperationStatus.Success); - expect(terminalProvider.getOutput()).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(run).toHaveBeenCalledTimes(2); @@ -391,7 +391,7 @@ describe(OperationExecutionManager.name, () => { expect(betaRequestRun).toBeDefined(); expect(result1).toBe(OperationStatus.Success); - expect(terminalProvider1.getOutput()).toMatchSnapshot('first'); + expect(terminalProvider1.getAllOutput(true)).toMatchSnapshot('first'); expect(runAlpha).toHaveBeenCalledTimes(1); expect(runBeta).toHaveBeenCalledTimes(1); @@ -423,7 +423,7 @@ describe(OperationExecutionManager.name, () => { }); expect(result2).toBe(OperationStatus.Success); - expect(terminalProvider2.getOutput()).toMatchSnapshot('second'); + expect(terminalProvider2.getAllOutput(true)).toMatchSnapshot('second'); expect(runAlpha).toHaveBeenCalledTimes(2); expect(runBeta).toHaveBeenCalledTimes(2); diff --git a/libraries/operation-graph/src/test/__snapshots__/OperationExecutionManager.test.ts.snap b/libraries/operation-graph/src/test/__snapshots__/OperationExecutionManager.test.ts.snap index 166654439b9..0de048fa27e 100644 --- a/libraries/operation-graph/src/test/__snapshots__/OperationExecutionManager.test.ts.snap +++ b/libraries/operation-graph/src/test/__snapshots__/OperationExecutionManager.test.ts.snap @@ -2,20 +2,56 @@ exports[`OperationExecutionManager constructor throws if a dependency is not in the set 1`] = `"Operation \\"alpha\\" declares a dependency on operation \\"beta\\" that is not in the set of operations to execute."`; -exports[`OperationExecutionManager executeAsync single pass blocks on failure 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass does not track noops 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass executes in order 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass handles empty input 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass handles trivial input 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass respects concurrency 1`] = `""`; - -exports[`OperationExecutionManager executeAsync single pass respects priority order 1`] = `""`; - -exports[`OperationExecutionManager executeAsync watch mode executes in order: first 1`] = `""`; - -exports[`OperationExecutionManager executeAsync watch mode executes in order: second 1`] = `""`; +exports[`OperationExecutionManager executeAsync single pass blocks on failure 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass does not track noops 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass executes in order 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass handles empty input 1`] = ` +Object { + "verbose": "Executing a maximum of 0 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass handles trivial input 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass respects concurrency 1`] = ` +Object { + "verbose": "Executing a maximum of 2 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync single pass respects priority order 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync watch mode executes in order: first 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; + +exports[`OperationExecutionManager executeAsync watch mode executes in order: second 1`] = ` +Object { + "verbose": "Executing a maximum of 1 simultaneous tasks...[n]", +} +`; diff --git a/libraries/rush-lib/src/api/test/CustomTipsConfiguration.test.ts b/libraries/rush-lib/src/api/test/CustomTipsConfiguration.test.ts index 1f6a769653d..1a38ebaea05 100644 --- a/libraries/rush-lib/src/api/test/CustomTipsConfiguration.test.ts +++ b/libraries/rush-lib/src/api/test/CustomTipsConfiguration.test.ts @@ -2,7 +2,12 @@ // See LICENSE in the project root for license information. import { JsonFile } from '@rushstack/node-core-library'; -import { PrintUtilities, StringBufferTerminalProvider, Terminal } from '@rushstack/terminal'; +import { + type IAllStringBufferOutput, + PrintUtilities, + StringBufferTerminalProvider, + Terminal +} from '@rushstack/terminal'; import { CustomTipId, CustomTipsConfiguration, type ICustomTipsJson } from '../CustomTipsConfiguration'; import { RushConfiguration } from '../RushConfiguration'; @@ -51,21 +56,14 @@ describe(CustomTipsConfiguration.name, () => { afterEach(() => { jest.restoreAllMocks(); - const outputLines: string[] = []; - function appendOutputLines(output: string, kind: string): void { - outputLines.push(`--- ${kind} ---`); - outputLines.push(...output.split('[n]')); - outputLines.push('-'.repeat(kind.length + 8)); + const terminalProviderOutput: Partial = terminalProvider.getAllOutput(true); + const lineSplitTerminalProviderOutput: Partial> = {}; + for (const [key, output] of Object.entries(terminalProviderOutput)) { + lineSplitTerminalProviderOutput[key as keyof IAllStringBufferOutput] = output.split('[n]'); } - appendOutputLines(terminalProvider.getOutput(), 'normal output'); - appendOutputLines(terminalProvider.getErrorOutput(), 'error output'); - appendOutputLines(terminalProvider.getWarningOutput(), 'warning output'); - appendOutputLines(terminalProvider.getVerboseOutput(), 'verbose output'); - appendOutputLines(terminalProvider.getDebugOutput(), 'debug output'); - - expect(outputLines).toMatchSnapshot(); + expect(lineSplitTerminalProviderOutput).toMatchSnapshot(); }); const printFunctions = [ diff --git a/libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts b/libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts index a1352f49fa1..914b9ecb186 100644 --- a/libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts +++ b/libraries/rush-lib/src/api/test/RushProjectConfiguration.test.ts @@ -63,10 +63,7 @@ function validateConfiguration(rushProjectConfiguration: RushProjectConfiguratio terminal ); } finally { - expect(terminalProvider.getOutput()).toMatchSnapshot('validation: terminal output'); - expect(terminalProvider.getErrorOutput()).toMatchSnapshot('validation: terminal error'); - expect(terminalProvider.getWarningOutput()).toMatchSnapshot('validation: terminal warning'); - expect(terminalProvider.getVerboseOutput()).toMatchSnapshot('validation: terminal verbose'); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); } } } @@ -86,16 +83,14 @@ function validateConfigurationWithParameters( ); rushProjectConfiguration.validatePhaseConfiguration( - Array.from(rushProjectConfiguration.operationSettingsByOperationName.keys(), + Array.from( + rushProjectConfiguration.operationSettingsByOperationName.keys(), (phaseName) => ({ name: phaseName, associatedParameters: mockParameters }) as IPhase ), terminal ); } finally { - expect(terminalProvider.getOutput()).toMatchSnapshot('validation: terminal output'); - expect(terminalProvider.getErrorOutput()).toMatchSnapshot('validation: terminal error'); - expect(terminalProvider.getWarningOutput()).toMatchSnapshot('validation: terminal warning'); - expect(terminalProvider.getVerboseOutput()).toMatchSnapshot('validation: terminal verbose'); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); } } } diff --git a/libraries/rush-lib/src/api/test/__snapshots__/CustomTipsConfiguration.test.ts.snap b/libraries/rush-lib/src/api/test/__snapshots__/CustomTipsConfiguration.test.ts.snap index 3aa0dc6648d..bc7d7e5a792 100644 --- a/libraries/rush-lib/src/api/test/__snapshots__/CustomTipsConfiguration.test.ts.snap +++ b/libraries/rush-lib/src/api/test/__snapshots__/CustomTipsConfiguration.test.ts.snap @@ -1,597 +1,402 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`CustomTipsConfiguration formatting (a long message with an indented line) _showErrorTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]Lorem ipsum dolor sit amet, consectetur", - "[red]| [default]adipiscing elit, sed do eiusmod tempor", - "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default]enim ad minim veniam, quis nostrud exercitation", - "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default]consequat. Duis aute irure dolor in", - "[red]| [default]reprehenderit in voluptate velit esse cillum", - "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default]occaecat cupidatat non proident, sunt in culpa", - "[red]| [default]qui officia deserunt mollit anim id est laborum.", - "[red]| [default] Lorem ipsum dolor sit amet, consectetur", - "[red]| [default] adipiscing elit, sed do eiusmod tempor", - "[red]| [default] incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default] enim ad minim veniam, quis nostrud exercitation", - "[red]| [default] ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default] consequat. Duis aute irure dolor in", - "[red]| [default] reprehenderit in voluptate velit esse cillum", - "[red]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default] occaecat cupidatat non proident, sunt in culpa", - "[red]| [default] qui officia deserunt mollit anim id est laborum.", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]Lorem ipsum dolor sit amet, consectetur", + "[red]| [default]adipiscing elit, sed do eiusmod tempor", + "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default]enim ad minim veniam, quis nostrud exercitation", + "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default]consequat. Duis aute irure dolor in", + "[red]| [default]reprehenderit in voluptate velit esse cillum", + "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default]occaecat cupidatat non proident, sunt in culpa", + "[red]| [default]qui officia deserunt mollit anim id est laborum.", + "[red]| [default] Lorem ipsum dolor sit amet, consectetur", + "[red]| [default] adipiscing elit, sed do eiusmod tempor", + "[red]| [default] incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default] enim ad minim veniam, quis nostrud exercitation", + "[red]| [default] ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default] consequat. Duis aute irure dolor in", + "[red]| [default] reprehenderit in voluptate velit esse cillum", + "[red]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default] occaecat cupidatat non proident, sunt in culpa", + "[red]| [default] qui officia deserunt mollit anim id est laborum.", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message with an indented line) _showInfoTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", - "|", - "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", - "| sed do eiusmod tempor incididunt ut labore et dolore magna", - "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", - "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", - "| Duis aute irure dolor in reprehenderit in voluptate velit", - "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", - "| sint occaecat cupidatat non proident, sunt in culpa qui", - "| officia deserunt mollit anim id est laborum.", - "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", - "| sed do eiusmod tempor incididunt ut labore et dolore magna", - "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", - "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", - "| Duis aute irure dolor in reprehenderit in voluptate velit", - "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", - "| sint occaecat cupidatat non proident, sunt in culpa qui", - "| officia deserunt mollit anim id est laborum.", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", + "|", + "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", + "| sed do eiusmod tempor incididunt ut labore et dolore magna", + "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", + "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "| Duis aute irure dolor in reprehenderit in voluptate velit", + "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", + "| sint occaecat cupidatat non proident, sunt in culpa qui", + "| officia deserunt mollit anim id est laborum.", + "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", + "| sed do eiusmod tempor incididunt ut labore et dolore magna", + "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", + "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "| Duis aute irure dolor in reprehenderit in voluptate velit", + "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", + "| sint occaecat cupidatat non proident, sunt in culpa qui", + "| officia deserunt mollit anim id est laborum.", + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message with an indented line) _showTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]Lorem ipsum dolor sit amet, consectetur", - "[red]| [default]adipiscing elit, sed do eiusmod tempor", - "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default]enim ad minim veniam, quis nostrud exercitation", - "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default]consequat. Duis aute irure dolor in", - "[red]| [default]reprehenderit in voluptate velit esse cillum", - "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default]occaecat cupidatat non proident, sunt in culpa", - "[red]| [default]qui officia deserunt mollit anim id est laborum.", - "[red]| [default] Lorem ipsum dolor sit amet, consectetur", - "[red]| [default] adipiscing elit, sed do eiusmod tempor", - "[red]| [default] incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default] enim ad minim veniam, quis nostrud exercitation", - "[red]| [default] ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default] consequat. Duis aute irure dolor in", - "[red]| [default] reprehenderit in voluptate velit esse cillum", - "[red]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default] occaecat cupidatat non proident, sunt in culpa", - "[red]| [default] qui officia deserunt mollit anim id est laborum.", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]Lorem ipsum dolor sit amet, consectetur", + "[red]| [default]adipiscing elit, sed do eiusmod tempor", + "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default]enim ad minim veniam, quis nostrud exercitation", + "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default]consequat. Duis aute irure dolor in", + "[red]| [default]reprehenderit in voluptate velit esse cillum", + "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default]occaecat cupidatat non proident, sunt in culpa", + "[red]| [default]qui officia deserunt mollit anim id est laborum.", + "[red]| [default] Lorem ipsum dolor sit amet, consectetur", + "[red]| [default] adipiscing elit, sed do eiusmod tempor", + "[red]| [default] incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default] enim ad minim veniam, quis nostrud exercitation", + "[red]| [default] ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default] consequat. Duis aute irure dolor in", + "[red]| [default] reprehenderit in voluptate velit esse cillum", + "[red]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default] occaecat cupidatat non proident, sunt in culpa", + "[red]| [default] qui officia deserunt mollit anim id est laborum.", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message with an indented line) _showWarningTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[yellow]|[default]", - "[yellow]| [default]Lorem ipsum dolor sit amet, consectetur", - "[yellow]| [default]adipiscing elit, sed do eiusmod tempor", - "[yellow]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[yellow]| [default]enim ad minim veniam, quis nostrud exercitation", - "[yellow]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[yellow]| [default]consequat. Duis aute irure dolor in", - "[yellow]| [default]reprehenderit in voluptate velit esse cillum", - "[yellow]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[yellow]| [default]occaecat cupidatat non proident, sunt in culpa", - "[yellow]| [default]qui officia deserunt mollit anim id est laborum.", - "[yellow]| [default] Lorem ipsum dolor sit amet, consectetur", - "[yellow]| [default] adipiscing elit, sed do eiusmod tempor", - "[yellow]| [default] incididunt ut labore et dolore magna aliqua. Ut", - "[yellow]| [default] enim ad minim veniam, quis nostrud exercitation", - "[yellow]| [default] ullamco laboris nisi ut aliquip ex ea commodo", - "[yellow]| [default] consequat. Duis aute irure dolor in", - "[yellow]| [default] reprehenderit in voluptate velit esse cillum", - "[yellow]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", - "[yellow]| [default] occaecat cupidatat non proident, sunt in culpa", - "[yellow]| [default] qui officia deserunt mollit anim id est laborum.", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "", + "", + ], + "warning": Array [ + "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[yellow]|[default]", + "[yellow]| [default]Lorem ipsum dolor sit amet, consectetur", + "[yellow]| [default]adipiscing elit, sed do eiusmod tempor", + "[yellow]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[yellow]| [default]enim ad minim veniam, quis nostrud exercitation", + "[yellow]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[yellow]| [default]consequat. Duis aute irure dolor in", + "[yellow]| [default]reprehenderit in voluptate velit esse cillum", + "[yellow]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[yellow]| [default]occaecat cupidatat non proident, sunt in culpa", + "[yellow]| [default]qui officia deserunt mollit anim id est laborum.", + "[yellow]| [default] Lorem ipsum dolor sit amet, consectetur", + "[yellow]| [default] adipiscing elit, sed do eiusmod tempor", + "[yellow]| [default] incididunt ut labore et dolore magna aliqua. Ut", + "[yellow]| [default] enim ad minim veniam, quis nostrud exercitation", + "[yellow]| [default] ullamco laboris nisi ut aliquip ex ea commodo", + "[yellow]| [default] consequat. Duis aute irure dolor in", + "[yellow]| [default] reprehenderit in voluptate velit esse cillum", + "[yellow]| [default] dolore eu fugiat nulla pariatur. Excepteur sint", + "[yellow]| [default] occaecat cupidatat non proident, sunt in culpa", + "[yellow]| [default] qui officia deserunt mollit anim id est laborum.", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message) _showErrorTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]Lorem ipsum dolor sit amet, consectetur", - "[red]| [default]adipiscing elit, sed do eiusmod tempor", - "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default]enim ad minim veniam, quis nostrud exercitation", - "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default]consequat. Duis aute irure dolor in", - "[red]| [default]reprehenderit in voluptate velit esse cillum", - "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default]occaecat cupidatat non proident, sunt in culpa", - "[red]| [default]qui officia deserunt mollit anim id est laborum.", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]Lorem ipsum dolor sit amet, consectetur", + "[red]| [default]adipiscing elit, sed do eiusmod tempor", + "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default]enim ad minim veniam, quis nostrud exercitation", + "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default]consequat. Duis aute irure dolor in", + "[red]| [default]reprehenderit in voluptate velit esse cillum", + "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default]occaecat cupidatat non proident, sunt in culpa", + "[red]| [default]qui officia deserunt mollit anim id est laborum.", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message) _showInfoTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", - "|", - "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", - "| sed do eiusmod tempor incididunt ut labore et dolore magna", - "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", - "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", - "| Duis aute irure dolor in reprehenderit in voluptate velit", - "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", - "| sint occaecat cupidatat non proident, sunt in culpa qui", - "| officia deserunt mollit anim id est laborum.", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", + "|", + "| Lorem ipsum dolor sit amet, consectetur adipiscing elit,", + "| sed do eiusmod tempor incididunt ut labore et dolore magna", + "| aliqua. Ut enim ad minim veniam, quis nostrud exercitation", + "| ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "| Duis aute irure dolor in reprehenderit in voluptate velit", + "| esse cillum dolore eu fugiat nulla pariatur. Excepteur", + "| sint occaecat cupidatat non proident, sunt in culpa qui", + "| officia deserunt mollit anim id est laborum.", + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message) _showTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]Lorem ipsum dolor sit amet, consectetur", - "[red]| [default]adipiscing elit, sed do eiusmod tempor", - "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[red]| [default]enim ad minim veniam, quis nostrud exercitation", - "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[red]| [default]consequat. Duis aute irure dolor in", - "[red]| [default]reprehenderit in voluptate velit esse cillum", - "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[red]| [default]occaecat cupidatat non proident, sunt in culpa", - "[red]| [default]qui officia deserunt mollit anim id est laborum.", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]Lorem ipsum dolor sit amet, consectetur", + "[red]| [default]adipiscing elit, sed do eiusmod tempor", + "[red]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[red]| [default]enim ad minim veniam, quis nostrud exercitation", + "[red]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[red]| [default]consequat. Duis aute irure dolor in", + "[red]| [default]reprehenderit in voluptate velit esse cillum", + "[red]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[red]| [default]occaecat cupidatat non proident, sunt in culpa", + "[red]| [default]qui officia deserunt mollit anim id est laborum.", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a long message) _showWarningTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[yellow]|[default]", - "[yellow]| [default]Lorem ipsum dolor sit amet, consectetur", - "[yellow]| [default]adipiscing elit, sed do eiusmod tempor", - "[yellow]| [default]incididunt ut labore et dolore magna aliqua. Ut", - "[yellow]| [default]enim ad minim veniam, quis nostrud exercitation", - "[yellow]| [default]ullamco laboris nisi ut aliquip ex ea commodo", - "[yellow]| [default]consequat. Duis aute irure dolor in", - "[yellow]| [default]reprehenderit in voluptate velit esse cillum", - "[yellow]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", - "[yellow]| [default]occaecat cupidatat non proident, sunt in culpa", - "[yellow]| [default]qui officia deserunt mollit anim id est laborum.", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "", + "", + ], + "warning": Array [ + "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[yellow]|[default]", + "[yellow]| [default]Lorem ipsum dolor sit amet, consectetur", + "[yellow]| [default]adipiscing elit, sed do eiusmod tempor", + "[yellow]| [default]incididunt ut labore et dolore magna aliqua. Ut", + "[yellow]| [default]enim ad minim veniam, quis nostrud exercitation", + "[yellow]| [default]ullamco laboris nisi ut aliquip ex ea commodo", + "[yellow]| [default]consequat. Duis aute irure dolor in", + "[yellow]| [default]reprehenderit in voluptate velit esse cillum", + "[yellow]| [default]dolore eu fugiat nulla pariatur. Excepteur sint", + "[yellow]| [default]occaecat cupidatat non proident, sunt in culpa", + "[yellow]| [default]qui officia deserunt mollit anim id est laborum.", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with an indented line) _showErrorTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "[red]| [default] This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "[red]| [default] This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with an indented line) _showInfoTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", - "|", - "| This is a test", - "| This is a test", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", + "|", + "| This is a test", + "| This is a test", + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with an indented line) _showTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "[red]| [default] This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "[red]| [default] This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with an indented line) _showWarningTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[yellow]|[default]", - "[yellow]| [default]This is a test", - "[yellow]| [default] This is a test", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "", + "", + ], + "warning": Array [ + "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[yellow]|[default]", + "[yellow]| [default]This is a test", + "[yellow]| [default] This is a test", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with newlines) _showErrorTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "[red]| [default]This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "[red]| [default]This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with newlines) _showInfoTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", - "|", - "| This is a test", - "| This is a test", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", + "|", + "| This is a test", + "| This is a test", + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with newlines) _showTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "[red]| [default]This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "[red]| [default]This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a message with newlines) _showWarningTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[yellow]|[default]", - "[yellow]| [default]This is a test", - "[yellow]| [default]This is a test", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "", + "", + ], + "warning": Array [ + "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[yellow]|[default]", + "[yellow]| [default]This is a test", + "[yellow]| [default]This is a test", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a short message) _showErrorTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a short message) _showInfoTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", - "|", - "| This is a test", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)", + "|", + "| This is a test", + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a short message) _showTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[red]|[default]", - "[red]| [default]This is a test", - "", - "--------------------", - "--- warning output ---", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "error": Array [ + "[red]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[red]|[default]", + "[red]| [default]This is a test", + "", + ], + "log": Array [ + "", + "", + ], +} `; exports[`CustomTipsConfiguration formatting (a short message) _showWarningTip prints an expected message 1`] = ` -Array [ - "--- normal output ---", - "", - "", - "---------------------", - "--- error output ---", - "", - "--------------------", - "--- warning output ---", - "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", - "[yellow]|[default]", - "[yellow]| [default]This is a test", - "", - "----------------------", - "--- verbose output ---", - "", - "----------------------", - "--- debug output ---", - "", - "--------------------", -] +Object { + "log": Array [ + "", + "", + ], + "warning": Array [ + "[yellow]| Custom Tip (TIP_PNPM_INVALID_NODE_VERSION)[default]", + "[yellow]|[default]", + "[yellow]| [default]This is a test", + "", + ], +} `; exports[`CustomTipsConfiguration loads the config file (custom-tips.json) 1`] = ` diff --git a/libraries/rush-lib/src/api/test/__snapshots__/RushProjectConfiguration.test.ts.snap b/libraries/rush-lib/src/api/test/__snapshots__/RushProjectConfiguration.test.ts.snap index 2ebe9d5908a..77b7f7c2bb4 100644 --- a/libraries/rush-lib/src/api/test/__snapshots__/RushProjectConfiguration.test.ts.snap +++ b/libraries/rush-lib/src/api/test/__snapshots__/RushProjectConfiguration.test.ts.snap @@ -10,7 +10,9 @@ exports[`RushProjectConfiguration getCacheDisabledReason Indicates if tracked fi exports[`RushProjectConfiguration getCacheDisabledReason returns reason if the operation is runnable 1`] = `"Caching has been disabled for this project's \\"_phase:a\\" command."`; -exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders 1`] = ` +exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders 1`] = `Object {}`; + +exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders 2`] = ` Map { "_phase:a" => Object { "disableBuildCacheForOperation": true, @@ -28,23 +30,15 @@ Map { } `; -exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders: validation: terminal error 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders: validation: terminal output 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders: validation: terminal verbose 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName allows outputFolderNames to be inside subfolders: validation: terminal warning 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName does not allow one outputFolderName to be under another: validation: terminal error 1`] = `"The project \\"test-project-d\\" has a \\"config/rush-project.json\\" configuration that defines two operations in the same command whose \\"outputFolderNames\\" would overlap. Operations outputs in the same command must be disjoint so that they can be independently cached. The \\"a/b\\" path overlaps between these operations: \\"_phase:b\\", \\"_phase:a\\"[n]"`; - -exports[`RushProjectConfiguration operationSettingsByOperationName does not allow one outputFolderName to be under another: validation: terminal output 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName does not allow one outputFolderName to be under another: validation: terminal verbose 1`] = `""`; +exports[`RushProjectConfiguration operationSettingsByOperationName does not allow one outputFolderName to be under another 1`] = ` +Object { + "error": "The project \\"test-project-d\\" has a \\"config/rush-project.json\\" configuration that defines two operations in the same command whose \\"outputFolderNames\\" would overlap. Operations outputs in the same command must be disjoint so that they can be independently cached. The \\"a/b\\" path overlaps between these operations: \\"_phase:b\\", \\"_phase:a\\"[n]", +} +`; -exports[`RushProjectConfiguration operationSettingsByOperationName does not allow one outputFolderName to be under another: validation: terminal warning 1`] = `""`; +exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file 1`] = `Object {}`; -exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file 1`] = ` +exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file 2`] = ` Map { "_phase:a" => Object { "operationName": "_phase:a", @@ -62,36 +56,22 @@ Map { } `; -exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file: validation: terminal error 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file: validation: terminal output 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file: validation: terminal verbose 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName loads a rush-project.json config that extends another config file: validation: terminal warning 1`] = `""`; - exports[`RushProjectConfiguration operationSettingsByOperationName throws an error when loading a rush-project.json config that lists an operation twice 1`] = `"The operation \\"_phase:a\\" occurs multiple times in the \\"operationSettings\\" array in \\"/config/rush-project.json\\"."`; -exports[`RushProjectConfiguration operationSettingsByOperationName validates mix of existent and nonexistent parameters: validation: terminal error 1`] = `"The project \\"test-project-g\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --nonexistent-param. Valid parameters for this operation are: --production, --verbose.[n]"`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates mix of existent and nonexistent parameters: validation: terminal output 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates mix of existent and nonexistent parameters: validation: terminal verbose 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates mix of existent and nonexistent parameters: validation: terminal warning 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates nonexistent parameters when operation has valid parameters: validation: terminal error 1`] = `"The project \\"test-project-f\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --nonexistent-param, --another-nonexistent. Valid parameters for this operation are: --production, --verbose.[n]"`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates nonexistent parameters when operation has valid parameters: validation: terminal output 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates nonexistent parameters when operation has valid parameters: validation: terminal verbose 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates nonexistent parameters when operation has valid parameters: validation: terminal warning 1`] = `""`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates that parameters in parameterNamesToIgnore exist for the operation: validation: terminal error 1`] = `"The project \\"test-project-e\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --invalid-parameter, --another-invalid, -malformed-parameter. Valid parameters for this operation are: (none).[n]"`; - -exports[`RushProjectConfiguration operationSettingsByOperationName validates that parameters in parameterNamesToIgnore exist for the operation: validation: terminal output 1`] = `""`; +exports[`RushProjectConfiguration operationSettingsByOperationName validates mix of existent and nonexistent parameters 1`] = ` +Object { + "error": "The project \\"test-project-g\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --nonexistent-param. Valid parameters for this operation are: --production, --verbose.[n]", +} +`; -exports[`RushProjectConfiguration operationSettingsByOperationName validates that parameters in parameterNamesToIgnore exist for the operation: validation: terminal verbose 1`] = `""`; +exports[`RushProjectConfiguration operationSettingsByOperationName validates nonexistent parameters when operation has valid parameters 1`] = ` +Object { + "error": "The project \\"test-project-f\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --nonexistent-param, --another-nonexistent. Valid parameters for this operation are: --production, --verbose.[n]", +} +`; -exports[`RushProjectConfiguration operationSettingsByOperationName validates that parameters in parameterNamesToIgnore exist for the operation: validation: terminal warning 1`] = `""`; +exports[`RushProjectConfiguration operationSettingsByOperationName validates that parameters in parameterNamesToIgnore exist for the operation 1`] = ` +Object { + "error": "The project \\"test-project-e\\" has a \\"config/rush-project.json\\" configuration that specifies invalid parameter(s) in \\"parameterNamesToIgnore\\" for operation \\"_phase:build\\": --invalid-parameter, --another-invalid, -malformed-parameter. Valid parameters for this operation are: (none).[n]", +} +`; diff --git a/libraries/rush-lib/src/logic/operations/test/BuildPlanPlugin.test.ts b/libraries/rush-lib/src/logic/operations/test/BuildPlanPlugin.test.ts index 20c1586e58f..b619d0a017f 100644 --- a/libraries/rush-lib/src/logic/operations/test/BuildPlanPlugin.test.ts +++ b/libraries/rush-lib/src/logic/operations/test/BuildPlanPlugin.test.ts @@ -138,7 +138,9 @@ describe(BuildPlanPlugin.name, () => { await hooks.beforeExecuteOperations.promise(operationMap, context as IExecuteOperationsContext); - expect(stringBufferTerminalProvider.getOutput({ normalizeSpecialCharacters: false })).toMatchSnapshot(); + expect( + stringBufferTerminalProvider.getAllOutput(true, { normalizeSpecialCharacters: false }) + ).toMatchSnapshot(); }); }); }); diff --git a/libraries/rush-lib/src/logic/operations/test/OperationMetadataManager.test.ts b/libraries/rush-lib/src/logic/operations/test/OperationMetadataManager.test.ts index 5663d143e39..13efc4415ee 100644 --- a/libraries/rush-lib/src/logic/operations/test/OperationMetadataManager.test.ts +++ b/libraries/rush-lib/src/logic/operations/test/OperationMetadataManager.test.ts @@ -63,7 +63,7 @@ describe(OperationMetadataManager.name, () => { errorLogPath: '/path/to/errorLog' }); - expect(mockTerminalProvider.getOutput()).toMatchSnapshot(); + expect(mockTerminalProvider.getAllOutput(true)).toMatchSnapshot(); expect(mockTerminalProvider.getWarningOutput()).toBeFalsy(); }); @@ -87,8 +87,7 @@ describe(OperationMetadataManager.name, () => { errorLogPath: '/path/to/errorLog' }); - expect(mockTerminalProvider.getOutput()).toBeFalsy(); - expect(mockTerminalProvider.getErrorOutput()).toMatchSnapshot(); + expect(mockTerminalProvider.getAllOutput(true)).toMatchSnapshot(); }); it('should restore mixed chunked output', async () => { @@ -110,11 +109,7 @@ describe(OperationMetadataManager.name, () => { terminalProvider: mockTerminalProvider, errorLogPath: '/path/to/errorLog' }); - - expect(mockTerminalProvider.getOutput().length).toBeGreaterThan(0); - expect(mockTerminalProvider.getOutput()).toMatchSnapshot(); - expect(mockTerminalProvider.getErrorOutput().length).toBeGreaterThan(0); - expect(mockTerminalProvider.getErrorOutput()).toMatchSnapshot(); + expect(mockTerminalProvider.getAllOutput(true)).toMatchSnapshot(); }); it("should fallback to the log file when chunked output isn't available", async () => { @@ -135,8 +130,7 @@ describe(OperationMetadataManager.name, () => { errorLogPath: '/path/to/errorLog' }); - expect(mockTerminalProvider.getOutput()).toBeFalsy(); - expect(mockTerminalProvider.getErrorOutput()).toBeFalsy(); + expect(mockTerminalProvider.getAllOutput(true)).toEqual({}); expect(mockClose).toHaveBeenCalledTimes(1); expect(mockWritable.chunks).toMatchSnapshot(); }); diff --git a/libraries/rush-lib/src/logic/operations/test/__snapshots__/BuildPlanPlugin.test.ts.snap b/libraries/rush-lib/src/logic/operations/test/__snapshots__/BuildPlanPlugin.test.ts.snap index b4a391ee2af..dcc43214583 100644 --- a/libraries/rush-lib/src/logic/operations/test/__snapshots__/BuildPlanPlugin.test.ts.snap +++ b/libraries/rush-lib/src/logic/operations/test/__snapshots__/BuildPlanPlugin.test.ts.snap @@ -1,7 +1,8 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`BuildPlanPlugin build plan debugging should generate a build plan 1`] = ` -"Build Plan Depth (deepest dependency tree): 5 +Object { + "log": "Build Plan Depth (deepest dependency tree): 5 Build Plan Width (maximum parallelism): 38 Number of Nodes per Depth: 22, 38, 33, 11, 1 Plan @ Depth 0 has 22 nodes and 0 dependents: @@ -321,5 +322,6 @@ Cluster 11: - Operations: j (upstream-1-self-upstream) -------------------------------------------------- ################################################## -" +", +} `; diff --git a/libraries/rush-lib/src/logic/operations/test/__snapshots__/OperationMetadataManager.test.ts.snap b/libraries/rush-lib/src/logic/operations/test/__snapshots__/OperationMetadataManager.test.ts.snap index 5647df50e1f..3c855cf2b6e 100644 --- a/libraries/rush-lib/src/logic/operations/test/__snapshots__/OperationMetadataManager.test.ts.snap +++ b/libraries/rush-lib/src/logic/operations/test/__snapshots__/OperationMetadataManager.test.ts.snap @@ -9,10 +9,21 @@ Array [ ] `; -exports[`OperationMetadataManager should restore chunked stderr 1`] = `"chunk1[n]chunk2[n]"`; - -exports[`OperationMetadataManager should restore chunked stdout 1`] = `"chunk1[n]chunk2[n]"`; +exports[`OperationMetadataManager should restore chunked stderr 1`] = ` +Object { + "error": "chunk1[n]chunk2[n]", +} +`; -exports[`OperationMetadataManager should restore mixed chunked output 1`] = `"logged to stdout[n]"`; +exports[`OperationMetadataManager should restore chunked stdout 1`] = ` +Object { + "log": "chunk1[n]chunk2[n]", +} +`; -exports[`OperationMetadataManager should restore mixed chunked output 2`] = `"logged to stderr[n]"`; +exports[`OperationMetadataManager should restore mixed chunked output 1`] = ` +Object { + "error": "logged to stderr[n]", + "log": "logged to stdout[n]", +} +`; diff --git a/libraries/rush-lib/src/logic/pnpm/test/PnpmShrinkwrapFile.test.ts b/libraries/rush-lib/src/logic/pnpm/test/PnpmShrinkwrapFile.test.ts index adc4ca5bd11..4e2ea90ab6a 100644 --- a/libraries/rush-lib/src/logic/pnpm/test/PnpmShrinkwrapFile.test.ts +++ b/libraries/rush-lib/src/logic/pnpm/test/PnpmShrinkwrapFile.test.ts @@ -546,13 +546,7 @@ snapshots: terminal ) ).toThrowError(AlreadyReportedError); - expect({ - log: terminalProvider.getOutput(), - warning: terminalProvider.getWarningOutput(), - error: terminalProvider.getErrorOutput(), - verbose: terminalProvider.getVerboseOutput(), - debug: terminalProvider.getDebugOutput() - }).toMatchSnapshot(); + expect(terminalProvider.getAllOutput(true)).toMatchSnapshot(); }); }); }); diff --git a/libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmShrinkwrapFile.test.ts.snap b/libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmShrinkwrapFile.test.ts.snap index 9135d73d008..490c95cfc42 100644 --- a/libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmShrinkwrapFile.test.ts.snap +++ b/libraries/rush-lib/src/logic/pnpm/test/__snapshots__/PnpmShrinkwrapFile.test.ts.snap @@ -2,10 +2,6 @@ exports[`PnpmShrinkwrapFile Check is workspace project modified pnpm lockfile major version 9 sha1 integrity can be handled when disallowInsecureSha1 1`] = ` Object { - "debug": "", "error": "Error: An integrity field with \\"sha1\\" was detected in the pnpm-lock.yaml file located in subspace default; this conflicts with the \\"disallowInsecureSha1\\" policy from pnpm-config.json.[n][n]", - "log": "", - "verbose": "", - "warning": "", } `; diff --git a/libraries/rush-lib/src/logic/test/InstallHelpers.test.ts b/libraries/rush-lib/src/logic/test/InstallHelpers.test.ts index 31acfc54516..e299e9ca845 100644 --- a/libraries/rush-lib/src/logic/test/InstallHelpers.test.ts +++ b/libraries/rush-lib/src/logic/test/InstallHelpers.test.ts @@ -25,13 +25,9 @@ describe('InstallHelpers', () => { }); afterEach(() => { - expect({ - output: terminalProvider.getOutput({ normalizeSpecialCharacters: true }), - verbose: terminalProvider.getVerbose({ normalizeSpecialCharacters: true }), - error: terminalProvider.getDebugOutput({ normalizeSpecialCharacters: true }), - warning: terminalProvider.getWarningOutput({ normalizeSpecialCharacters: true }), - debug: terminalProvider.getDebugOutput({ normalizeSpecialCharacters: true }) - }).toMatchSnapshot('Terminal Output'); + expect(terminalProvider.getAllOutput(true, { normalizeSpecialCharacters: true })).toMatchSnapshot( + 'Terminal Output' + ); mockJsonFileSave.mockClear(); }); diff --git a/libraries/rush-lib/src/logic/test/ProjectChangeAnalyzer.test.ts b/libraries/rush-lib/src/logic/test/ProjectChangeAnalyzer.test.ts index df3d771a17b..b90254d5652 100644 --- a/libraries/rush-lib/src/logic/test/ProjectChangeAnalyzer.test.ts +++ b/libraries/rush-lib/src/logic/test/ProjectChangeAnalyzer.test.ts @@ -157,9 +157,7 @@ describe(ProjectChangeAnalyzer.name, () => { const snapshot: IInputsSnapshot | undefined = await snapshotProvider?.(); expect(snapshot).toBe(mockSnapshotValue); - expect(terminalProvider.getErrorOutput()).toEqual(''); - expect(terminalProvider.getWarningOutput()).toEqual(''); - + expect(terminalProvider.getAllOutput(true)).toEqual({}); expect(mockSnapshot).toHaveBeenCalledTimes(1); const mockInput: IInputsSnapshotParameters = mockSnapshot.mock.calls[0][0]; diff --git a/libraries/rush-lib/src/logic/test/ProjectImpactGraphGenerator.test.ts b/libraries/rush-lib/src/logic/test/ProjectImpactGraphGenerator.test.ts index 89213fdb03b..c5ff1d2c738 100644 --- a/libraries/rush-lib/src/logic/test/ProjectImpactGraphGenerator.test.ts +++ b/libraries/rush-lib/src/logic/test/ProjectImpactGraphGenerator.test.ts @@ -22,13 +22,9 @@ async function runTestForExampleRepoAsync( const generator: ProjectImpactGraphGenerator = new ProjectImpactGraphGenerator(terminal, rushConfiguration); await testFn(generator); - expect({ - output: terminalProvider.getOutput({ normalizeSpecialCharacters: true }), - verbose: terminalProvider.getVerbose({ normalizeSpecialCharacters: true }), - error: terminalProvider.getDebugOutput({ normalizeSpecialCharacters: true }), - warning: terminalProvider.getWarningOutput({ normalizeSpecialCharacters: true }), - debug: terminalProvider.getDebugOutput({ normalizeSpecialCharacters: true }) - }).toMatchSnapshot('Terminal Output'); + expect(terminalProvider.getAllOutput(true, { normalizeSpecialCharacters: true })).toMatchSnapshot( + 'Terminal Output' + ); } describe(ProjectImpactGraphGenerator.name, () => { diff --git a/libraries/rush-lib/src/logic/test/__snapshots__/InstallHelpers.test.ts.snap b/libraries/rush-lib/src/logic/test/__snapshots__/InstallHelpers.test.ts.snap index 7f122921b53..12d290aeb65 100644 --- a/libraries/rush-lib/src/logic/test/__snapshots__/InstallHelpers.test.ts.snap +++ b/libraries/rush-lib/src/logic/test/__snapshots__/InstallHelpers.test.ts.snap @@ -1,11 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`InstallHelpers generateCommonPackageJson generates correct package json with pnpm configurations: Terminal Output 1`] = ` -Object { - "debug": "", - "error": "", - "output": "", - "verbose": "", - "warning": "", -} -`; +exports[`InstallHelpers generateCommonPackageJson generates correct package json with pnpm configurations: Terminal Output 1`] = `Object {}`; diff --git a/libraries/rush-lib/src/logic/test/__snapshots__/ProjectImpactGraphGenerator.test.ts.snap b/libraries/rush-lib/src/logic/test/__snapshots__/ProjectImpactGraphGenerator.test.ts.snap index f784a772885..73d78358b5b 100644 --- a/libraries/rush-lib/src/logic/test/__snapshots__/ProjectImpactGraphGenerator.test.ts.snap +++ b/libraries/rush-lib/src/logic/test/__snapshots__/ProjectImpactGraphGenerator.test.ts.snap @@ -93,11 +93,7 @@ exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project impact graph (repo: ""packages""): Terminal Output 1`] = ` Object { - "debug": "", - "error": "", - "output": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", - "verbose": "", - "warning": "", + "log": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", } `; @@ -170,11 +166,7 @@ exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project impact graph (repo: ""repo""): Terminal Output 1`] = ` Object { - "debug": "", - "error": "", - "output": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", - "verbose": "", - "warning": "", + "log": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", } `; @@ -273,20 +265,8 @@ exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project exports[`ProjectImpactGraphGenerator generateAsync Correctly generates a project impact graph (repo: ""workspacePackages""): Terminal Output 1`] = ` Object { - "debug": "", - "error": "", - "output": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", - "verbose": "", - "warning": "", + "log": "[n][green]Generate project impact graph successfully. (1.50 seconds)[default][n]", } `; -exports[`ProjectImpactGraphGenerator validateAsync Reports if the project-impact-graph.yaml file is missing (repo: ""workspacePackages""): Terminal Output 1`] = ` -Object { - "debug": "", - "error": "", - "output": "", - "verbose": "", - "warning": "", -} -`; +exports[`ProjectImpactGraphGenerator validateAsync Reports if the project-impact-graph.yaml file is missing (repo: ""workspacePackages""): Terminal Output 1`] = `Object {}`; diff --git a/libraries/terminal/src/StringBufferTerminalProvider.ts b/libraries/terminal/src/StringBufferTerminalProvider.ts index 5c57b6a9237..9f6d83bb0c1 100644 --- a/libraries/terminal/src/StringBufferTerminalProvider.ts +++ b/libraries/terminal/src/StringBufferTerminalProvider.ts @@ -19,6 +19,33 @@ export interface IStringBufferOutputOptions { normalizeSpecialCharacters: boolean; } +/** + * @beta + */ +export interface IAllStringBufferOutput { + log: string; + warning: string; + error: string; + verbose: string; + debug: string; +} + +function _normalizeOutput(s: string, options: IStringBufferOutputOptions | undefined): string { + options = { + normalizeSpecialCharacters: true, + + ...(options || {}) + }; + + s = Text.convertToLf(s); + + if (options.normalizeSpecialCharacters) { + return AnsiEscape.formatForTests(s, { encodeNewlines: true }); + } else { + return s; + } +} + /** * Terminal provider that stores written data in buffers separated by severity. * This terminal provider is designed to be used when code that prints to a terminal @@ -33,10 +60,13 @@ export class StringBufferTerminalProvider implements ITerminalProvider { private _warningBuffer: StringBuilder = new StringBuilder(); private _errorBuffer: StringBuilder = new StringBuilder(); - private _supportsColor: boolean; + /** + * {@inheritDoc ITerminalProvider.supportsColor} + */ + public readonly supportsColor: boolean; public constructor(supportsColor: boolean = false) { - this._supportsColor = supportsColor; + this.supportsColor = supportsColor; } /** @@ -79,18 +109,11 @@ export class StringBufferTerminalProvider implements ITerminalProvider { return '\n'; } - /** - * {@inheritDoc ITerminalProvider.supportsColor} - */ - public get supportsColor(): boolean { - return this._supportsColor; - } - /** * Get everything that has been written at log-level severity. */ public getOutput(options?: IStringBufferOutputOptions): string { - return this._normalizeOutput(this._standardBuffer.toString(), options); + return _normalizeOutput(this._standardBuffer.toString(), options); } /** @@ -104,43 +127,66 @@ export class StringBufferTerminalProvider implements ITerminalProvider { * Get everything that has been written at verbose-level severity. */ public getVerboseOutput(options?: IStringBufferOutputOptions): string { - return this._normalizeOutput(this._verboseBuffer.toString(), options); + return _normalizeOutput(this._verboseBuffer.toString(), options); } /** * Get everything that has been written at debug-level severity. */ public getDebugOutput(options?: IStringBufferOutputOptions): string { - return this._normalizeOutput(this._debugBuffer.toString(), options); + return _normalizeOutput(this._debugBuffer.toString(), options); } /** * Get everything that has been written at error-level severity. */ public getErrorOutput(options?: IStringBufferOutputOptions): string { - return this._normalizeOutput(this._errorBuffer.toString(), options); + return _normalizeOutput(this._errorBuffer.toString(), options); } /** * Get everything that has been written at warning-level severity. */ public getWarningOutput(options?: IStringBufferOutputOptions): string { - return this._normalizeOutput(this._warningBuffer.toString(), options); + return _normalizeOutput(this._warningBuffer.toString(), options); } - private _normalizeOutput(s: string, options: IStringBufferOutputOptions | undefined): string { - options = { - normalizeSpecialCharacters: true, + /** + * Get everything that has been written at all severity levels. + */ + public getAllOutput(sparse?: false, options?: IStringBufferOutputOptions): IAllStringBufferOutput; + public getAllOutput(sparse: true, options?: IStringBufferOutputOptions): Partial; + public getAllOutput( + sparse: boolean | undefined, + options?: IStringBufferOutputOptions + ): Partial { + const result: Partial = {}; + + const log: string = this.getOutput(options); + if (!sparse || log) { + result.log = log; + } + + const warning: string = this.getWarningOutput(options); + if (!sparse || warning) { + result.warning = warning; + } - ...(options || {}) - }; + const error: string = this.getErrorOutput(options); + if (!sparse || error) { + result.error = error; + } - s = Text.convertToLf(s); + const verbose: string = this.getVerboseOutput(options); + if (!sparse || verbose) { + result.verbose = verbose; + } - if (options.normalizeSpecialCharacters) { - return AnsiEscape.formatForTests(s, { encodeNewlines: true }); - } else { - return s; + const debug: string = this.getDebugOutput(options); + if (!sparse || debug) { + result.debug = debug; } + + return result; } } diff --git a/libraries/terminal/src/index.ts b/libraries/terminal/src/index.ts index 3824681927b..2254e40b9fc 100644 --- a/libraries/terminal/src/index.ts +++ b/libraries/terminal/src/index.ts @@ -39,7 +39,8 @@ export { type ITerminalProvider, TerminalProviderSeverity } from './ITerminalPro export { ConsoleTerminalProvider, type IConsoleTerminalProviderOptions } from './ConsoleTerminalProvider'; export { StringBufferTerminalProvider, - type IStringBufferOutputOptions + type IStringBufferOutputOptions, + type IAllStringBufferOutput } from './StringBufferTerminalProvider'; export { PrefixProxyTerminalProvider, diff --git a/libraries/terminal/src/test/PrefixProxyTerminalProvider.test.ts b/libraries/terminal/src/test/PrefixProxyTerminalProvider.test.ts index c0a69b8b960..e42c7da62ce 100644 --- a/libraries/terminal/src/test/PrefixProxyTerminalProvider.test.ts +++ b/libraries/terminal/src/test/PrefixProxyTerminalProvider.test.ts @@ -13,13 +13,7 @@ function runTestsForTerminalProvider( let baseProvider: StringBufferTerminalProvider; function verifyProvider(): void { - expect({ - log: baseProvider.getOutput(), - warning: baseProvider.getWarningOutput(), - error: baseProvider.getErrorOutput(), - verbose: baseProvider.getVerboseOutput(), - debug: baseProvider.getDebugOutput() - }).toMatchSnapshot(); + expect(baseProvider.getAllOutput(true)).toMatchSnapshot(); } beforeEach(() => { diff --git a/libraries/terminal/src/test/PrintUtilities.test.ts b/libraries/terminal/src/test/PrintUtilities.test.ts index 81fc2e51526..f90cf0807ae 100644 --- a/libraries/terminal/src/test/PrintUtilities.test.ts +++ b/libraries/terminal/src/test/PrintUtilities.test.ts @@ -99,8 +99,8 @@ describe(PrintUtilities.name, () => { describe(PrintUtilities.printMessageInBox.name, () => { function validateOutput(expectedWidth: number): void { const outputLines: string[] = terminalProvider - .getOutput({ normalizeSpecialCharacters: true }) - .split('[n]'); + .getOutput({ normalizeSpecialCharacters: false }) + .split('\n'); expect(outputLines).toMatchSnapshot(); expect(outputLines.every((x) => x.length <= expectedWidth)); diff --git a/libraries/terminal/src/test/Terminal.test.ts b/libraries/terminal/src/test/Terminal.test.ts index 903432963df..a76fb2e1ef7 100644 --- a/libraries/terminal/src/test/Terminal.test.ts +++ b/libraries/terminal/src/test/Terminal.test.ts @@ -10,13 +10,7 @@ describe(Terminal.name, () => { let provider: StringBufferTerminalProvider; function verifyProvider(): void { - expect({ - log: provider.getOutput(), - warning: provider.getWarningOutput(), - error: provider.getErrorOutput(), - verbose: provider.getVerboseOutput(), - debug: provider.getDebugOutput() - }).toMatchSnapshot(); + expect(provider.getAllOutput()).toMatchSnapshot(); } describe('01 color enabled', () => { diff --git a/libraries/terminal/src/test/TerminalStreamWritable.test.ts b/libraries/terminal/src/test/TerminalStreamWritable.test.ts index a44a4150fde..ef3fac18089 100644 --- a/libraries/terminal/src/test/TerminalStreamWritable.test.ts +++ b/libraries/terminal/src/test/TerminalStreamWritable.test.ts @@ -11,13 +11,7 @@ let terminal: Terminal; let provider: StringBufferTerminalProvider; function verifyProvider(): void { - expect({ - log: provider.getOutput(), - warning: provider.getWarningOutput(), - error: provider.getErrorOutput(), - verbose: provider.getVerboseOutput(), - debug: provider.getDebugOutput() - }).toMatchSnapshot(); + expect(provider.getAllOutput()).toMatchSnapshot(); } async function writeAsync(writable: Writable, data: string): Promise { diff --git a/libraries/terminal/src/test/__snapshots__/PrefixProxyTerminalProvider.test.ts.snap b/libraries/terminal/src/test/__snapshots__/PrefixProxyTerminalProvider.test.ts.snap index 561059efad4..003d1fc8b0f 100644 --- a/libraries/terminal/src/test/__snapshots__/PrefixProxyTerminalProvider.test.ts.snap +++ b/libraries/terminal/src/test/__snapshots__/PrefixProxyTerminalProvider.test.ts.snap @@ -2,180 +2,108 @@ exports[`PrefixProxyTerminalProvider With a dynamic prefix write writes a message 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] test message", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix write writes a message with newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1[n][prefix (1)] message 2[n][prefix (2)] message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix write writes a message with provider newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1[n][prefix (1)] message 2[n][prefix (2)] message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix write writes a mix of messages with and without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1message 2[n][prefix (1)] message 3[n][prefix (2)] message 4message 5[n][prefix (3)] message 6", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix write writes messages without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1message 2message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix writeLine writes a message line 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] test message[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix writeLine writes a message line with newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1[n][prefix (1)] message 2[n][prefix (2)] message 3[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix writeLine writes a message line with provider newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1[n][prefix (1)] message 2[n][prefix (2)] message 3[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a dynamic prefix writeLine writes a mix of message lines with and without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix (0)] message 1[n][prefix (1)] message 2[n][prefix (2)] message 3[n][prefix (3)] [n][prefix (4)] message 4[n][prefix (5)] message 5[n][prefix (6)] message 6[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix write writes a message 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] test message", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix write writes a message with newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1[n][prefix] message 2[n][prefix] message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix write writes a message with provider newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1[n][prefix] message 2[n][prefix] message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix write writes a mix of messages with and without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1message 2[n][prefix] message 3[n][prefix] message 4message 5[n][prefix] message 6", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix write writes messages without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1message 2message 3", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix writeLine writes a message line 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] test message[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix writeLine writes a message line with newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1[n][prefix] message 2[n][prefix] message 3[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix writeLine writes a message line with provider newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1[n][prefix] message 2[n][prefix] message 3[n]", - "verbose": "", - "warning": "", } `; exports[`PrefixProxyTerminalProvider With a static prefix writeLine writes a mix of message lines with and without newlines 1`] = ` Object { - "debug": "", - "error": "", "log": "[prefix] message 1[n][prefix] message 2[n][prefix] message 3[n][prefix] [n][prefix] message 4[n][prefix] message 5[n][prefix] message 6[n]", - "verbose": "", - "warning": "", } `; diff --git a/libraries/typings-generator/src/test/StringValuesTypingsGenerator.test.ts b/libraries/typings-generator/src/test/StringValuesTypingsGenerator.test.ts index 2a0b4f79237..5d57eef149e 100644 --- a/libraries/typings-generator/src/test/StringValuesTypingsGenerator.test.ts +++ b/libraries/typings-generator/src/test/StringValuesTypingsGenerator.test.ts @@ -82,11 +82,7 @@ describe('StringValuesTypingsGenerator', () => { await generator.generateTypingsAsync(['test.ext']); expect(outputFs).toMatchSnapshot(); - expect(terminalProvider.getOutput()).toEqual(''); - expect(terminalProvider.getWarningOutput()).toEqual(''); - expect(terminalProvider.getErrorOutput()).toEqual(''); - expect(terminalProvider.getVerboseOutput()).toEqual(''); - expect(terminalProvider.getDebugOutput()).toEqual(''); + expect(terminalProvider.getAllOutput(true)).toEqual({}); }); } diff --git a/rush-plugins/rush-http-build-cache-plugin/src/test/HttpBuildCacheProvider.test.ts b/rush-plugins/rush-http-build-cache-plugin/src/test/HttpBuildCacheProvider.test.ts index 463c238d2e6..053ee007dda 100644 --- a/rush-plugins/rush-http-build-cache-plugin/src/test/HttpBuildCacheProvider.test.ts +++ b/rush-plugins/rush-http-build-cache-plugin/src/test/HttpBuildCacheProvider.test.ts @@ -66,9 +66,12 @@ describe('HttpBuildCacheProvider', () => { redirect: 'follow' }) ); - expect(terminalBuffer.getWarningOutput()).toMatchInlineSnapshot( - `"Error getting cache entry: Error: Credentials for https://buildcache.example.acme.com/ have not been provided.[n]In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.[n][n]For local developers, run:[n][n] rush update-cloud-credentials --interactive[n][n]"` - ); + expect(terminalBuffer.getAllOutput(true)).toMatchInlineSnapshot(` +Object { + "debug": "[http-build-cache] request: GET https://buildcache.example.acme.com/some-key unknown bytes[n]", + "warning": "Error getting cache entry: Error: Credentials for https://buildcache.example.acme.com/ have not been provided.[n]In CI, verify that RUSH_BUILD_CACHE_CREDENTIAL contains a valid Authorization header value.[n][n]For local developers, run:[n][n] rush update-cloud-credentials --interactive[n][n]", +} +`); }); it('attempts up to 3 times to download a cache entry', async () => { @@ -120,9 +123,12 @@ describe('HttpBuildCacheProvider', () => { redirect: 'follow' }) ); - expect(terminalBuffer.getWarningOutput()).toMatchInlineSnapshot( - `"Could not get cache entry: HTTP 504: BadGateway[n]"` - ); + expect(terminalBuffer.getAllOutput(true)).toMatchInlineSnapshot(` +Object { + "debug": "[http-build-cache] request: GET https://buildcache.example.acme.com/some-key unknown bytes[n][http-build-cache] request: GET https://buildcache.example.acme.com/some-key unknown bytes[n][http-build-cache] request: GET https://buildcache.example.acme.com/some-key unknown bytes[n]", + "warning": "Could not get cache entry: HTTP 504: BadGateway[n]", +} +`); }); }); });