From 64fa8abb55e92ef0dca43729271224cec2a6412a Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 6 Feb 2022 09:00:46 +0100 Subject: [PATCH 1/3] feat(pretty-format): expose `ConvertAnsi` plugin --- jest.config.js | 4 +--- packages/pretty-format/package.json | 3 ++- scripts/buildUtils.js | 3 +++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/jest.config.js b/jest.config.js index 98103ffa7447..c54992993b8a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -34,9 +34,7 @@ module.exports = { snapshotFormat: { escapeString: false, }, - snapshotSerializers: [ - '/packages/pretty-format/build/plugins/ConvertAnsi.js', - ], + snapshotSerializers: [require.resolve('pretty-format/ConvertAnsi')], testPathIgnorePatterns: [ '/__arbitraries__/', '/__typetests__/', diff --git a/packages/pretty-format/package.json b/packages/pretty-format/package.json index 3a5638554d6b..144ac1c2078a 100644 --- a/packages/pretty-format/package.json +++ b/packages/pretty-format/package.json @@ -15,7 +15,8 @@ "types": "./build/index.d.ts", "default": "./build/index.js" }, - "./package.json": "./package.json" + "./package.json": "./package.json", + "./ConvertAnsi": "./build/plugins/ConvertAnsi.js" }, "author": "James Kyle ", "dependencies": { diff --git a/scripts/buildUtils.js b/scripts/buildUtils.js index d2ba6ba08fc6..5f69966efaf1 100644 --- a/scripts/buildUtils.js +++ b/scripts/buildUtils.js @@ -65,6 +65,9 @@ module.exports.getPackages = function getPackages() { './build/utils': './build/utils.js', } : {}), + ...(pkg.name === 'pretty-format' + ? {'./ConvertAnsi': './build/plugins/ConvertAnsi.js'} + : {}), }, `Package ${pkg.name} does not export correct files`, ); From d14f994be9360300d44dfb05e6d2b03572d5a1f8 Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 6 Feb 2022 09:04:11 +0100 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38e17f9242ff..9eb466ffdd77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ### Features +- `[pretty-format]` Expose `ConvertAnsi` plugin ([#12308](https://github.com/facebook/jest/pull/12308)) + ### Fixes - `[expect]` Add type definitions for asymmetric `closeTo` matcher ([#12304](https://github.com/facebook/jest/pull/12304)) From 1efd13725ca989e8bad835a885d982c4f6af9d2b Mon Sep 17 00:00:00 2001 From: Simen Bekkhus Date: Sun, 6 Feb 2022 09:19:03 +0100 Subject: [PATCH 3/3] node 10 --- jest.config.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jest.config.js b/jest.config.js index c54992993b8a..15d7bd48491b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -34,7 +34,10 @@ module.exports = { snapshotFormat: { escapeString: false, }, - snapshotSerializers: [require.resolve('pretty-format/ConvertAnsi')], + snapshotSerializers: [ + // change to require.resolve('pretty-format/ConvertAnsi') when we drop Node 10 + '/packages/pretty-format/build/plugins/ConvertAnsi.js', + ], testPathIgnorePatterns: [ '/__arbitraries__/', '/__typetests__/',