diff --git a/package-lock.json b/package-lock.json index 84ff86f62..35fcc511d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9683,6 +9683,12 @@ "node_modules/@quarterto/strip-ansi": { "version": "1.2.0" }, + "node_modules/@relmify/jest-serializer-strip-ansi": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@relmify/jest-serializer-strip-ansi/-/jest-serializer-strip-ansi-1.0.2.tgz", + "integrity": "sha512-cJv6weXt7Bk0PEpWNtw0UGOddIbEvNLPlbYb+594xxe5WXs3SSA29tCK57Vg6q46wHEpY1kOCmgQhE8EcIXPKw==", + "dev": true + }, "node_modules/@serverless/dashboard-plugin": { "version": "6.2.3", "resolved": "https://registry.npmjs.org/@serverless/dashboard-plugin/-/dashboard-plugin-6.2.3.tgz", @@ -32400,6 +32406,7 @@ "pluralize": "^8.0.0" }, "devDependencies": { + "@relmify/jest-serializer-strip-ansi": "^1.0.2", "@types/npmcli__map-workspaces": "^3.0.4", "@types/pluralize": "^0.0.33" }, diff --git a/plugins/monorepo/package.json b/plugins/monorepo/package.json index b08e91bd6..6a5a1a5ff 100644 --- a/plugins/monorepo/package.json +++ b/plugins/monorepo/package.json @@ -38,6 +38,7 @@ "pluralize": "^8.0.0" }, "devDependencies": { + "@relmify/jest-serializer-strip-ansi": "^1.0.2", "@types/npmcli__map-workspaces": "^3.0.4", "@types/pluralize": "^0.0.33" } diff --git a/plugins/monorepo/test/load-workspace-configs.test.ts b/plugins/monorepo/test/load-workspace-configs.test.ts index cfe41117b..9b0d037f7 100644 --- a/plugins/monorepo/test/load-workspace-configs.test.ts +++ b/plugins/monorepo/test/load-workspace-configs.test.ts @@ -1,9 +1,12 @@ import path from 'path' import LoadWorkspaceConfigs from '../src/load-workspace-configs' import winston, { Logger } from 'winston' +import { stripAnsi } from '@relmify/jest-serializer-strip-ansi' const logger = winston as unknown as Logger +expect.addSnapshotSerializer(stripAnsi) + expect.addSnapshotSerializer({ test(value) { return value instanceof Error && value.name === 'AggregateError' @@ -26,13 +29,13 @@ expect.addSnapshotSerializer({ }, serialize(val, config, indentation, depth, refs, printer) { - return `${val.name} ${printer(val.message, config, indentation, depth, refs)} ${printer( - { details: val.details }, + return `${printer(val.name, config, indentation, depth, refs)} ${printer( + val.message, config, indentation, depth, refs - )}` + )} ${printer({ details: val.details }, config, indentation, depth, refs)}` } }) @@ -62,19 +65,19 @@ describe('LoadWorkspaceConfigs', () => { cwd: path.relative(process.cwd(), path.resolve(__dirname, './files/invalid')) }) ).rejects.toMatchInlineSnapshot(` - AggregateError "2 errors loading .toolkitrc.yml in workspace packages" { + AggregateError "2 errors loading .toolkitrc.yml in workspace packages" { "errors": [ - @monorepo-plugin-tests/b → ToolKitError "There are options in your .toolkitrc.yml that aren't what Tool Kit expected." { + "@monorepo-plugin-tests/b → ToolKitError" "There are options in your .toolkitrc.yml that aren't what Tool Kit expected." { "details": "Please update the options so that they are the expected types. -  !  2 issues in @dotcom-tool-kit/serverless: + ! 2 issues in @dotcom-tool-kit/serverless: - Required at "awsAccountId" - Required at "systemCode" You can refer to the README for the plugin for examples and descriptions of the options used.", }, - @monorepo-plugin-tests/c → ToolKitError "There are options in your .toolkitrc.yml that aren't what Tool Kit expected." { + "@monorepo-plugin-tests/c → ToolKitError" "There are options in your .toolkitrc.yml that aren't what Tool Kit expected." { "details": "Please update the options so that they are the expected types. -  !  1 issue in @dotcom-tool-kit/heroku: + ! 1 issue in @dotcom-tool-kit/heroku: - Required at "pipeline" You can refer to the README for the plugin for examples and descriptions of the options used.",