From 74aed92c9ce701ebfba7f97ab288b00dd6f8b9ad Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 24 Aug 2019 10:24:31 -0400 Subject: [PATCH 1/7] jest-diff: Export Diff constructor as value instead of type --- packages/jest-diff/README.md | 88 ++++++++++++------- .../src/__tests__/diffStringsRaw.test.ts | 35 ++++++++ packages/jest-diff/src/index.ts | 10 +-- packages/jest-matcher-utils/src/index.ts | 6 +- 4 files changed, 99 insertions(+), 40 deletions(-) create mode 100644 packages/jest-diff/src/__tests__/diffStringsRaw.test.ts diff --git a/packages/jest-diff/README.md b/packages/jest-diff/README.md index d60e630be761..0f511783c766 100644 --- a/packages/jest-diff/README.md +++ b/packages/jest-diff/README.md @@ -26,8 +26,8 @@ Given values and optional options, `diffLinesUnified(a, b, options?)` does the f To use this function, write either of the following: -- `const diffLinesUnified = require('jest-diff');` in a CommonJS module -- `import diffLinesUnified from 'jest-diff';` in an ECMAScript module +- `const diffLinesUnified = require('jest-diff');` in CommonJS modules +- `import diffLinesUnified from 'jest-diff';` in ECMAScript or TypeScript modules ### Example of default export @@ -40,8 +40,7 @@ const difference = diffLinesUnified(a, b); The returned **string** consists of: -- annotation lines which describe the change symbols with labels -- blank line +- annotation lines: describe the two change symbols with labels, and a blank line - comparison lines: similar to “unified” view on GitHub, but `Expected` lines are green, `Received` lines are red, and common lines are dim (by default, see Options) ```diff @@ -77,8 +76,8 @@ Although the function is mainly for **multiline** strings, it compares any strin Write either of the following: -- `const {diffStringsUnified} = require('jest-diff');` in a CommonJS module -- `import {diffStringsUnified} from 'jest-diff';` in an ECMAScript module +- `const {diffStringsUnified} = require('jest-diff');` in CommonJS modules +- `import {diffStringsUnified} from 'jest-diff';` in ECMAScript or TypeScript modules ### Example of diffStringsUnified @@ -91,9 +90,8 @@ const difference = diffStringsUnified(a, b); The returned **string** consists of: -- annotation lines which describe the change symbols with labels -- blank line -- comparison lines: similar to “unified” view on GitHub, and **changed substrings** have **inverted** foreground and background colors +- annotation lines: describe the two change symbols with labels, and a blank line +- comparison lines: similar to “unified” view on GitHub, and **changed substrings** have **inverted** foreground and background colors (which the following example does not show) ```diff - Expected @@ -121,18 +119,21 @@ If the input strings can have **arbitrary length**, we recommend that the callin ## Usage of diffStringsRaw -Given strings, `diffStringsRaw(a, b, cleanup)` does the following: +Given strings and boolean, `diffStringsRaw(a, b, cleanup)` does the following: - **compare** the strings character-by-character using the `diff-sequences` package - optionally **clean up** small (often coincidental) common substrings, also known as chaff Write one of the following: -- `const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, diffStringsRaw} = require('jest-diff');` in a CommonJS module -- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, diffStringsRaw} from 'jest-diff';` in an ECMAScript module -- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in a TypeScript module +- `const {diffStringsRaw} = require('jest-diff');` in CommonJS modules +- `import {diffStringsRaw} from 'jest-diff';` in ECMAScript or TypeScript modules -The returned **array** describes substrings as instances of the `Diff` class (which calling code can access like array tuples). +Because `diffStringsRaw` returns the difference as **data** instead of a string, you can format it as your application requires (for example, enclosed in HTML markup for browser instead of escape sequences for console). + +The returned **array** describes substrings as instances of the `Diff` class, which calling code can access like array tuples: + +The value at index `0` is one of the following: | value | named export | description | | ----: | :------------ | :-------------------- | @@ -140,21 +141,23 @@ The returned **array** describes substrings as instances of the `Diff` class (wh | `-1` | `DIFF_DELETE` | in `a` but not in `b` | | `1` | `DIFF_INSERT` | in `b` but not in `a` | -Because `diffStringsRaw` returns the difference as **data** instead of a string, you are free to format it as your application requires (for example, enclosed in HTML markup for browser instead of escape sequences for console). +The value at index `1` is a substring of `a` or `b` or both. ### Example of diffStringsRaw with cleanup ```js const diffs = diffStringsRaw('change from', 'change to', true); -// diffs[0][0] === DIFF_EQUAL -// diffs[0][1] === 'change ' +/* +diffs[0][0] === 0 // DIFF_EQUAL +diffs[0][1] === 'change ' -// diffs[1][0] === DIFF_DELETE -// diffs[1][1] === 'from' +diffs[1][0] === -1 // DIFF_DELETE +diffs[1][1] === 'from' -// diffs[2][0] === DIFF_INSERT -// diffs[2][1] === 'to' +diffs[2][0] === 1 // DIFF_INSERT +diffs[2][1] === 'to' +*/ ``` ### Example of diffStringsRaw without cleanup @@ -162,21 +165,44 @@ const diffs = diffStringsRaw('change from', 'change to', true); ```js const diffs = diffStringsRaw('change from', 'change to', false); -// diffs[0][0] === DIFF_EQUAL -// diffs[0][1] === 'change ' +/* +diffs[0][0] === 0 // DIFF_EQUAL +diffs[0][1] === 'change ' -// diffs[1][0] === DIFF_DELETE -// diffs[1][1] === 'fr' +diffs[1][0] === -1 // DIFF_DELETE +diffs[1][1] === 'fr' -// diffs[2][0] === DIFF_INSERT -// diffs[2][1] === 't' +diffs[2][0] === 1 // DIFF_INSERT +diffs[2][1] === 't' // Here is a small coincidental common substring: -// diffs[3][0] === DIFF_EQUAL -// diffs[3][1] === 'o' +diffs[3][0] === 0 // DIFF_EQUAL +diffs[3][1] === 'o' + +diffs[4][0] === -1 // DIFF_DELETE +diffs[4][1] === 'm' +*/ +``` + +## Advanced import for diffStringsRaw + +Here are all the named imports for the `diffStringsRaw` function: -// diffs[4][0] === DIFF_DELETE -// diffs[4][1] === 'm' +- `const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = require('jest-diff');` in CommonJS modules +- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in ECMAScript or TypeScript modules + +If you write TypeScript declarations like `diff: Diff` or `diffs: Array` in a **formatting** function, then `error TS2749: 'Diff' refers to a value, but is being used as a type here.` means you need to declare the **instance** type of the **constructor** function type, as follows: + +```ts +type Diff = InstanceType; +``` + +If you write an application-specific **cleanup** algorithm, then you might need to call the `Diff` constructor: + +```js +const diffCommon = new Diff(DIFF_EQUAL, 'change '); +const diffDelete = new Diff(DIFF_DELETE, 'from'); +const diffInsert = new Diff(DIFF_INSERT, 'to'); ``` ## Options diff --git a/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts b/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts new file mode 100644 index 000000000000..e027881468ec --- /dev/null +++ b/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts @@ -0,0 +1,35 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +import jestDiff = require('../'); +const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = jestDiff; + +describe('diffStringsRaw', () => { + test('one-line with cleanup', () => { + const expected: Array = [ + new Diff(DIFF_EQUAL, 'change '), + new Diff(DIFF_DELETE, 'from'), + new Diff(DIFF_INSERT, 'to'), + ]; + const received = diffStringsRaw('change from', 'change to', true); + + expect(received).toEqual(expected); + }); + + test('one-line without cleanup', () => { + const expected: Array = [ + new Diff(DIFF_EQUAL, 'change '), + new Diff(DIFF_DELETE, 'fr'), + new Diff(DIFF_INSERT, 't'), + new Diff(DIFF_EQUAL, 'o'), + new Diff(DIFF_DELETE, 'm'), + ]; + const received = diffStringsRaw('change from', 'change to', false); + + expect(received).toEqual(expected); + }); +}); diff --git a/packages/jest-diff/src/index.ts b/packages/jest-diff/src/index.ts index df6cd5a140a9..a2eaf009e4bb 100644 --- a/packages/jest-diff/src/index.ts +++ b/packages/jest-diff/src/index.ts @@ -8,12 +8,7 @@ import prettyFormat = require('pretty-format'); import chalk from 'chalk'; import getType = require('jest-get-type'); -import { - DIFF_DELETE, - DIFF_EQUAL, - DIFF_INSERT, - Diff as DiffClass, -} from './cleanupSemantic'; +import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; import diffLines from './diffLines'; import {normalizeDiffOptions} from './normalizeDiffOptions'; import {diffStringsRaw, diffStringsUnified} from './printDiffs'; @@ -165,14 +160,15 @@ function compareObjects( // eslint-disable-next-line no-redeclare namespace diff { - export type Diff = DiffClass; export type DiffOptions = JestDiffOptions; } diff.diffStringsUnified = diffStringsUnified; + diff.diffStringsRaw = diffStringsRaw; diff.DIFF_DELETE = DIFF_DELETE; diff.DIFF_EQUAL = DIFF_EQUAL; diff.DIFF_INSERT = DIFF_INSERT; +diff.Diff = Diff; export = diff; diff --git a/packages/jest-matcher-utils/src/index.ts b/packages/jest-matcher-utils/src/index.ts index aba7ff29812e..af92d5bd257b 100644 --- a/packages/jest-matcher-utils/src/index.ts +++ b/packages/jest-matcher-utils/src/index.ts @@ -14,9 +14,11 @@ const { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, + Diff, diffStringsRaw, diffStringsUnified, } = jestDiff; +type Diff = InstanceType; const { AsymmetricMatcher, @@ -226,12 +228,12 @@ export const ensureExpectedIsNonNegativeInteger = ( // * include change substrings which have argument op // with inverse highlight only if there is a common substring const getCommonAndChangedSubstrings = ( - diffs: Array, + diffs: Array, op: number, hasCommonDiff: boolean, ): string => diffs.reduce( - (reduced: string, diff: jestDiff.Diff): string => + (reduced: string, diff: Diff): string => reduced + (diff[0] === DIFF_EQUAL ? diff[1] From 6fa0e5a26f4857a69adf6c7ec98da926bc6d0054 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 24 Aug 2019 13:49:24 -0400 Subject: [PATCH 2/7] Rewrite as ECMAScript-TypeScript module --- packages/jest-diff/README.md | 6 +---- .../src/__tests__/diffStringsRaw.test.ts | 3 +-- packages/jest-diff/src/index.ts | 24 +++++-------------- packages/jest-matcher-utils/src/index.ts | 18 +++++++------- packages/jest-snapshot/src/print.ts | 4 ++-- 5 files changed, 18 insertions(+), 37 deletions(-) diff --git a/packages/jest-diff/README.md b/packages/jest-diff/README.md index 0f511783c766..c11beeaecd92 100644 --- a/packages/jest-diff/README.md +++ b/packages/jest-diff/README.md @@ -191,11 +191,7 @@ Here are all the named imports for the `diffStringsRaw` function: - `const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = require('jest-diff');` in CommonJS modules - `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in ECMAScript or TypeScript modules -If you write TypeScript declarations like `diff: Diff` or `diffs: Array` in a **formatting** function, then `error TS2749: 'Diff' refers to a value, but is being used as a type here.` means you need to declare the **instance** type of the **constructor** function type, as follows: - -```ts -type Diff = InstanceType; -``` +To write a **formatting** function, you might need the named constants (and `Diff` in TypeScript annotations). If you write an application-specific **cleanup** algorithm, then you might need to call the `Diff` constructor: diff --git a/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts b/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts index e027881468ec..330310b58f7d 100644 --- a/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts +++ b/packages/jest-diff/src/__tests__/diffStringsRaw.test.ts @@ -5,8 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import jestDiff = require('../'); -const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = jestDiff; +import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from '../'; describe('diffStringsRaw', () => { test('one-line with cleanup', () => { diff --git a/packages/jest-diff/src/index.ts b/packages/jest-diff/src/index.ts index a2eaf009e4bb..f36d30957a67 100644 --- a/packages/jest-diff/src/index.ts +++ b/packages/jest-diff/src/index.ts @@ -8,12 +8,13 @@ import prettyFormat = require('pretty-format'); import chalk from 'chalk'; import getType = require('jest-get-type'); -import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; +export {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; import diffLines from './diffLines'; import {normalizeDiffOptions} from './normalizeDiffOptions'; -import {diffStringsRaw, diffStringsUnified} from './printDiffs'; +export {diffStringsRaw, diffStringsUnified} from './printDiffs'; import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants'; -import {DiffOptionsNormalized, DiffOptions as JestDiffOptions} from './types'; +import {DiffOptionsNormalized, DiffOptions as ImportDiffOptions} from './types'; +export type DiffOptions = ImportDiffOptions; const { AsymmetricMatcher, @@ -45,7 +46,7 @@ const FALLBACK_FORMAT_OPTIONS_0 = {...FALLBACK_FORMAT_OPTIONS, indent: 0}; // Generate a string that will highlight the difference between two values // with green and red. (similar to how github does code diffing) -function diff(a: any, b: any, options?: JestDiffOptions): string | null { +function diff(a: any, b: any, options?: DiffOptions): string | null { if (Object.is(a, b)) { return NO_DIFF_MESSAGE; } @@ -158,17 +159,4 @@ function compareObjects( return diffMessage; } -// eslint-disable-next-line no-redeclare -namespace diff { - export type DiffOptions = JestDiffOptions; -} - -diff.diffStringsUnified = diffStringsUnified; - -diff.diffStringsRaw = diffStringsRaw; -diff.DIFF_DELETE = DIFF_DELETE; -diff.DIFF_EQUAL = DIFF_EQUAL; -diff.DIFF_INSERT = DIFF_INSERT; -diff.Diff = Diff; - -export = diff; +export default diff; diff --git a/packages/jest-matcher-utils/src/index.ts b/packages/jest-matcher-utils/src/index.ts index af92d5bd257b..2d03613e4a6a 100644 --- a/packages/jest-matcher-utils/src/index.ts +++ b/packages/jest-matcher-utils/src/index.ts @@ -6,19 +6,17 @@ */ import chalk from 'chalk'; -import jestDiff = require('jest-diff'); -import getType = require('jest-get-type'); -import prettyFormat = require('pretty-format'); - -const { +import diffLinesUnified, { DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, + DiffOptions as ImportDiffOptions, diffStringsRaw, diffStringsUnified, -} = jestDiff; -type Diff = InstanceType; +} from 'jest-diff'; +import getType = require('jest-get-type'); +import prettyFormat = require('pretty-format'); const { AsymmetricMatcher, @@ -51,7 +49,7 @@ export type MatcherHintOptions = { secondArgumentColor?: MatcherHintColor; }; -export type DiffOptions = jestDiff.DiffOptions; +export type DiffOptions = ImportDiffOptions; export const EXPECTED_COLOR = chalk.green; export const RECEIVED_COLOR = chalk.red; @@ -340,7 +338,7 @@ export const printDiffOrStringify = ( } if (isLineDiffable(expected, received)) { - const difference = jestDiff(expected, received, { + const difference = diffLinesUnified(expected, received, { aAnnotation: expectedLabel, bAnnotation: receivedLabel, expand, @@ -380,7 +378,7 @@ const shouldPrintDiff = (actual: unknown, expected: unknown) => { }; export const diff = (a: any, b: any, options?: DiffOptions): string | null => - shouldPrintDiff(a, b) ? jestDiff(a, b, options) : null; + shouldPrintDiff(a, b) ? diffLinesUnified(a, b, options) : null; export const pluralize = (word: string, count: number) => (NUMBERS[count] || count) + ' ' + word + (count === 1 ? '' : 's'); diff --git a/packages/jest-snapshot/src/print.ts b/packages/jest-snapshot/src/print.ts index 4f0516f91bf2..c59df18106f5 100644 --- a/packages/jest-snapshot/src/print.ts +++ b/packages/jest-snapshot/src/print.ts @@ -5,7 +5,7 @@ * LICENSE file in the root directory of this source tree. */ -import diff = require('jest-diff'); +import diff, {diffStringsUnified} from 'jest-diff'; import getType = require('jest-get-type'); import { EXPECTED_COLOR, @@ -86,7 +86,7 @@ export const printDiffOrStringified = ( receivedSerializedTrimmed.length <= MAX_DIFF_STRING_LENGTH && expectedSerializedTrimmed !== receivedSerializedTrimmed ) { - return diff.diffStringsUnified( + return diffStringsUnified( expectedSerializedTrimmed, receivedSerializedTrimmed, { From 4bd6783a88ddf3831008ca8b3033aea3d5bfac4e Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 24 Aug 2019 13:56:35 -0400 Subject: [PATCH 3/7] Delete or TypeScript in README --- packages/jest-diff/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/jest-diff/README.md b/packages/jest-diff/README.md index c11beeaecd92..a964173185cd 100644 --- a/packages/jest-diff/README.md +++ b/packages/jest-diff/README.md @@ -27,7 +27,7 @@ Given values and optional options, `diffLinesUnified(a, b, options?)` does the f To use this function, write either of the following: - `const diffLinesUnified = require('jest-diff');` in CommonJS modules -- `import diffLinesUnified from 'jest-diff';` in ECMAScript or TypeScript modules +- `import diffLinesUnified from 'jest-diff';` in ECMAScript modules ### Example of default export @@ -77,7 +77,7 @@ Although the function is mainly for **multiline** strings, it compares any strin Write either of the following: - `const {diffStringsUnified} = require('jest-diff');` in CommonJS modules -- `import {diffStringsUnified} from 'jest-diff';` in ECMAScript or TypeScript modules +- `import {diffStringsUnified} from 'jest-diff';` in ECMAScript modules ### Example of diffStringsUnified @@ -127,7 +127,7 @@ Given strings and boolean, `diffStringsRaw(a, b, cleanup)` does the following: Write one of the following: - `const {diffStringsRaw} = require('jest-diff');` in CommonJS modules -- `import {diffStringsRaw} from 'jest-diff';` in ECMAScript or TypeScript modules +- `import {diffStringsRaw} from 'jest-diff';` in ECMAScript modules Because `diffStringsRaw` returns the difference as **data** instead of a string, you can format it as your application requires (for example, enclosed in HTML markup for browser instead of escape sequences for console). @@ -189,7 +189,7 @@ diffs[4][1] === 'm' Here are all the named imports for the `diffStringsRaw` function: - `const {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} = require('jest-diff');` in CommonJS modules -- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in ECMAScript or TypeScript modules +- `import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff, diffStringsRaw} from 'jest-diff';` in ECMAScript modules To write a **formatting** function, you might need the named constants (and `Diff` in TypeScript annotations). From 8cd1b95bd06fb96a8d5fcf75fe93f45d02a467b5 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 24 Aug 2019 14:19:14 -0400 Subject: [PATCH 4/7] Add .default to example of CommonJS default export in README --- packages/jest-diff/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/jest-diff/README.md b/packages/jest-diff/README.md index a964173185cd..822e6c2d619b 100644 --- a/packages/jest-diff/README.md +++ b/packages/jest-diff/README.md @@ -26,7 +26,7 @@ Given values and optional options, `diffLinesUnified(a, b, options?)` does the f To use this function, write either of the following: -- `const diffLinesUnified = require('jest-diff');` in CommonJS modules +- `const diffLinesUnified = require('jest-diff').default;` in CommonJS modules - `import diffLinesUnified from 'jest-diff';` in ECMAScript modules ### Example of default export From 4364f48b0e9ecb5b6aad4f5c88fb525f1106f38f Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Sat, 24 Aug 2019 14:45:30 -0400 Subject: [PATCH 5/7] Rename and add as BREAKING to CHANGELOG --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 49322624ffe0..e5da5d0e3908 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - `[babel-plugin-jest-hoist]` Show codeframe on static hoisting issues ([#8865](https://github.com/facebook/jest/pull/8865)) - `[jest-config]` [**BREAKING**] Set default display name color based on runner ([#8689](https://github.com/facebook/jest/pull/8689)) - `[jest-diff]` Add options for colors and symbols ([#8841](https://github.com/facebook/jest/pull/8841)) +- `[jest-diff]` [**BREAKING**] Rewrite as ECMAScript module ([#8873](https://github.com/facebook/jest/pull/8873)) - `[jest-runner]` Warn if a worker had to be force exited ([#8206](https://github.com/facebook/jest/pull/8206)) - `[@jest/test-result]` Create method to create empty `TestResult` ([#8867](https://github.com/facebook/jest/pull/8867)) - `[jest-worker]` [**BREAKING**] Return a promise from `end()`, resolving with the information whether workers exited gracefully ([#8206](https://github.com/facebook/jest/pull/8206)) From 3a01d65f5c34f7ff31240f139b06bbd77dd68ff1 Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 26 Aug 2019 10:37:07 -0400 Subject: [PATCH 6/7] Rewrite re-export as explicit import and export statements --- packages/jest-diff/src/index.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/jest-diff/src/index.ts b/packages/jest-diff/src/index.ts index f36d30957a67..76cbb7c34dae 100644 --- a/packages/jest-diff/src/index.ts +++ b/packages/jest-diff/src/index.ts @@ -8,14 +8,18 @@ import prettyFormat = require('pretty-format'); import chalk from 'chalk'; import getType = require('jest-get-type'); -export {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; +import {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff} from './cleanupSemantic'; import diffLines from './diffLines'; import {normalizeDiffOptions} from './normalizeDiffOptions'; -export {diffStringsRaw, diffStringsUnified} from './printDiffs'; +import {diffStringsRaw, diffStringsUnified} from './printDiffs'; import {NO_DIFF_MESSAGE, SIMILAR_MESSAGE} from './constants'; import {DiffOptionsNormalized, DiffOptions as ImportDiffOptions} from './types'; + export type DiffOptions = ImportDiffOptions; +export {diffStringsRaw, diffStringsUnified}; +export {DIFF_DELETE, DIFF_EQUAL, DIFF_INSERT, Diff}; + const { AsymmetricMatcher, DOMCollection, From 056ecc7405cbebec389e00b400bcbb4f46edba5f Mon Sep 17 00:00:00 2001 From: Mark Pedrotti Date: Mon, 26 Aug 2019 10:38:10 -0400 Subject: [PATCH 7/7] Edit description in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e5da5d0e3908..37614b8b64f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - `[babel-plugin-jest-hoist]` Show codeframe on static hoisting issues ([#8865](https://github.com/facebook/jest/pull/8865)) - `[jest-config]` [**BREAKING**] Set default display name color based on runner ([#8689](https://github.com/facebook/jest/pull/8689)) - `[jest-diff]` Add options for colors and symbols ([#8841](https://github.com/facebook/jest/pull/8841)) -- `[jest-diff]` [**BREAKING**] Rewrite as ECMAScript module ([#8873](https://github.com/facebook/jest/pull/8873)) +- `[jest-diff]` [**BREAKING**] Export as ECMAScript module ([#8873](https://github.com/facebook/jest/pull/8873)) - `[jest-runner]` Warn if a worker had to be force exited ([#8206](https://github.com/facebook/jest/pull/8206)) - `[@jest/test-result]` Create method to create empty `TestResult` ([#8867](https://github.com/facebook/jest/pull/8867)) - `[jest-worker]` [**BREAKING**] Return a promise from `end()`, resolving with the information whether workers exited gracefully ([#8206](https://github.com/facebook/jest/pull/8206))