diff --git a/tests/checks/PrismaClientOnContext.test.ts b/tests/checks/PrismaClientOnContext.test.ts index 056448a64..3b031f537 100644 --- a/tests/checks/PrismaClientOnContext.test.ts +++ b/tests/checks/PrismaClientOnContext.test.ts @@ -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: ` @@ -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 $2') + result.logs[0] = result.logs[0]!.replace( + /(.*imported from).*(is not the.*)/, + '$1 $2' + ).replace(ansiEscapeSequencePattern, '') } expect(result.logs).toMatchSnapshot(`logs`) expect(result.graphqlSchemaSDL).toMatchSnapshot(`graphqlSchemaSDL`) diff --git a/tsconfig.json b/tsconfig.json index 04eb8948f..596d0fdf1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -29,6 +29,6 @@ ".nexus-prisma": [".nexus-prisma"] } }, - "include": ["src", "tests", "scripts"], + "include": ["src", "tests", "scripts", "utils"], "exclude": ["dist-*", "tests/e2e/fixtures", "docs"] } diff --git a/utils/ansiEscapeSequencePattern.ts b/utils/ansiEscapeSequencePattern.ts new file mode 100644 index 000000000..a6d3914ba --- /dev/null +++ b/utils/ansiEscapeSequencePattern.ts @@ -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