From 31a179d978651b018fc4d420beb8f75ec13f63ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20De=20Boey?= Date: Sun, 25 Apr 2021 18:31:07 +0200 Subject: [PATCH] chore: use jest-snapshot-serializer-raw/always as unquoteSerializer (#204) --- package.json | 1 + src/__tests__/index.js | 2 +- src/scripts/__tests__/format.js | 4 +++- src/scripts/__tests__/helpers/serializers.js | 6 ------ src/scripts/__tests__/lint.js | 8 +++----- src/scripts/__tests__/precommit.js | 4 +++- src/scripts/__tests__/test.js | 2 +- src/scripts/__tests__/validate.js | 2 +- 8 files changed, 13 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index b858c340..044f50dc 100644 --- a/package.json +++ b/package.json @@ -117,6 +117,7 @@ "homepage": "https://github.com/kentcdodds/kcd-scripts#readme", "devDependencies": { "jest-in-case": "^1.0.2", + "jest-snapshot-serializer-raw": "^1.2.0", "slash": "^3.0.0" } } diff --git a/src/__tests__/index.js b/src/__tests__/index.js index 00dab083..bcbd2cd8 100644 --- a/src/__tests__/index.js +++ b/src/__tests__/index.js @@ -1,7 +1,7 @@ import path from 'path' import slash from 'slash' import cases from 'jest-in-case' -import {unquoteSerializer} from '../scripts/__tests__/helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' const projectRoot = path.join(__dirname, '../../') diff --git a/src/scripts/__tests__/format.js b/src/scripts/__tests__/format.js index ec798516..55a5354c 100644 --- a/src/scripts/__tests__/format.js +++ b/src/scripts/__tests__/format.js @@ -1,5 +1,7 @@ import cases from 'jest-in-case' -import {unquoteSerializer, winPathSerializer} from './helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' + +import {winPathSerializer} from './helpers/serializers' expect.addSnapshotSerializer(unquoteSerializer) expect.addSnapshotSerializer(winPathSerializer) diff --git a/src/scripts/__tests__/helpers/serializers.js b/src/scripts/__tests__/helpers/serializers.js index 683d9dee..0620518b 100644 --- a/src/scripts/__tests__/helpers/serializers.js +++ b/src/scripts/__tests__/helpers/serializers.js @@ -1,11 +1,5 @@ import slash from 'slash' -// this removes the quotes around strings... -export const unquoteSerializer = { - print: val => val, - test: val => typeof val === 'string', -} - // this converts windows style file paths to unix... export const winPathSerializer = { print: val => slash(val), diff --git a/src/scripts/__tests__/lint.js b/src/scripts/__tests__/lint.js index d3c0c3bf..0f87734c 100644 --- a/src/scripts/__tests__/lint.js +++ b/src/scripts/__tests__/lint.js @@ -1,9 +1,7 @@ import cases from 'jest-in-case' -import { - unquoteSerializer, - winPathSerializer, - relativePathSerializer, -} from './helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' + +import {winPathSerializer, relativePathSerializer} from './helpers/serializers' expect.addSnapshotSerializer(unquoteSerializer) expect.addSnapshotSerializer(winPathSerializer) diff --git a/src/scripts/__tests__/precommit.js b/src/scripts/__tests__/precommit.js index 12f653bc..0de088b9 100644 --- a/src/scripts/__tests__/precommit.js +++ b/src/scripts/__tests__/precommit.js @@ -1,5 +1,7 @@ import cases from 'jest-in-case' -import {unquoteSerializer, winPathSerializer} from './helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' + +import {winPathSerializer} from './helpers/serializers' expect.addSnapshotSerializer(unquoteSerializer) expect.addSnapshotSerializer(winPathSerializer) diff --git a/src/scripts/__tests__/test.js b/src/scripts/__tests__/test.js index 8f763795..75c20e43 100644 --- a/src/scripts/__tests__/test.js +++ b/src/scripts/__tests__/test.js @@ -1,5 +1,5 @@ import cases from 'jest-in-case' -import {unquoteSerializer} from './helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' jest.mock('jest', () => ({run: jest.fn()})) jest.mock('../../config/jest.config', () => ({builtInConfig: true})) diff --git a/src/scripts/__tests__/validate.js b/src/scripts/__tests__/validate.js index 6a6b4909..3998a235 100644 --- a/src/scripts/__tests__/validate.js +++ b/src/scripts/__tests__/validate.js @@ -1,5 +1,5 @@ import cases from 'jest-in-case' -import {unquoteSerializer} from './helpers/serializers' +import * as unquoteSerializer from 'jest-snapshot-serializer-raw/always' expect.addSnapshotSerializer(unquoteSerializer)