Skip to content

Commit

Permalink
test(monorepo): strip ansi in snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
apaleslimghost committed Dec 2, 2024
1 parent 782400e commit 5b34628
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions plugins/monorepo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
19 changes: 11 additions & 8 deletions plugins/monorepo/test/load-workspace-configs.test.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)}`
}
})

Expand Down Expand Up @@ -62,19 +65,19 @@ describe('LoadWorkspaceConfigs', () => {
cwd: path.relative(process.cwd(), path.resolve(__dirname, './files/invalid'))
})
).rejects.toMatchInlineSnapshot(`
AggregateError "2 errors loading [3m.toolkitrc.yml[23m in workspace packages" {
AggregateError "2 errors loading .toolkitrc.yml in workspace packages" {
"errors": [
[36m@monorepo-plugin-tests/b[39m → ToolKitError "There are options in your [3m.toolkitrc.yml[23m 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.
[43m[30m ! [39m[49m 2 issues in [36m[36m@dotcom-tool-kit/serverless[39m[36m[39m:
! 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.",
},
[36m@monorepo-plugin-tests/c[39m → ToolKitError "There are options in your [3m.toolkitrc.yml[23m 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.
[43m[30m ! [39m[49m 1 issue in [36m[36m@dotcom-tool-kit/heroku[39m[36m[39m:
! 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.",
Expand Down

0 comments on commit 5b34628

Please sign in to comment.