Skip to content

Commit

Permalink
fix: remove colors from the the result to fix the local test (#225)
Browse files Browse the repository at this point in the history
* remove colors from the the result to fix the local test

* eslint-disable-next-line no-control-regex
  • Loading branch information
AhmedElywa authored Aug 10, 2022
1 parent 6af7859 commit 684fa20
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion tests/checks/PrismaClientOnContext.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import gql from 'graphql-tag'
import { objectType, queryType } from 'nexus'
import { testIntegration, TestIntegrationParams, testIntegrationPartial } from '../__helpers__/testers'
import { ansiEscapeSequencePattern } from '../../utils/ansiEscapeSequencePattern'

const base = testIntegrationPartial({
database: `
Expand Down Expand Up @@ -96,7 +97,10 @@ describe('instanceOf_duckType_fallback strategy:', () => {
// The emitted error contains a path that isn't stable across the CI/CI matrix. Needs to be processed.
expect(result) {
if (result.logs[0]) {
result.logs[0] = result.logs[0]!.replace(/(.*imported from).*(is not the.*)/, '$1 <dynamic_path> $2')
result.logs[0] = result.logs[0]!.replace(
/(.*imported from).*(is not the.*)/,
'$1 <dynamic_path> $2'
).replace(ansiEscapeSequencePattern, '')
}
expect(result.logs).toMatchSnapshot(`logs`)
expect(result.graphqlSchemaSDL).toMatchSnapshot(`graphqlSchemaSDL`)
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@
".nexus-prisma": [".nexus-prisma"]
}
},
"include": ["src", "tests", "scripts"],
"include": ["src", "tests", "scripts", "utils"],
"exclude": ["dist-*", "tests/e2e/fixtures", "docs"]
}
5 changes: 5 additions & 0 deletions utils/ansiEscapeSequencePattern.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @see https://stackoverflow.com/questions/4842424/list-of-ansi-color-escape-sequences
*/
// eslint-disable-next-line no-control-regex
export const ansiEscapeSequencePattern = /\x1b\[[0-9]+m/g

1 comment on commit 684fa20

@vercel
Copy link

@vercel vercel bot commented on 684fa20 Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.