diff --git a/.eslintignore b/.eslintignore
index e2b3e6c..dd87e2d 100644
--- a/.eslintignore
+++ b/.eslintignore
@@ -1,3 +1,2 @@
node_modules
-flow-typed
build
diff --git a/.eslintrc.json b/.eslintrc.json
index 837107f..2951a55 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -2,9 +2,8 @@
"extends": "@callstack",
"rules": {
"global-require": 0,
- "flowtype/no-weak-types": 0,
"strict": [0, "global"],
- "no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
+ "@typescript-eslint/no-unused-vars": ["error", { "argsIgnorePattern": "^_" }],
"react-native/no-raw-text": 0
}
}
diff --git a/.flowconfig b/.flowconfig
deleted file mode 100644
index a9fe4ec..0000000
--- a/.flowconfig
+++ /dev/null
@@ -1,2 +0,0 @@
-[ignore]
-.*/node_modules/resolve/test/resolver/malformed_package_json/package.json
diff --git a/.npmignore b/.npmignore
index d10fdc8..5820022 100644
--- a/.npmignore
+++ b/.npmignore
@@ -1,5 +1,4 @@
src
__tests__
-flow-typed
yarn.lock
.eslintcache
diff --git a/__tests__/getSnapshotDiffSerializer.test.js b/__tests__/getSnapshotDiffSerializer.test.js
index c075a5d..2454988 100644
--- a/__tests__/getSnapshotDiffSerializer.test.js
+++ b/__tests__/getSnapshotDiffSerializer.test.js
@@ -1,8 +1,6 @@
-// @flow
+const { snapshotDiff, getSnapshotDiffSerializer } = require('../src/index');
-const snapshotDiff = require('../src/index');
-// $FlowFixMe – wrong type declaration in flow-typed/jest@20.x.x
-expect.addSnapshotSerializer(snapshotDiff.getSnapshotDiffSerializer());
+expect.addSnapshotSerializer(getSnapshotDiffSerializer());
test('serialize text diff output', () => {
expect(
diff --git a/__tests__/index.test.js b/__tests__/index.test.js
index 4085ac9..6fffb8f 100644
--- a/__tests__/index.test.js
+++ b/__tests__/index.test.js
@@ -1,18 +1,15 @@
test('public api', () => {
- const index = require('../src/index');
+ const index = require('../build/index');
- expect(index).toBeInstanceOf(Function);
- expect(index.snapshotDiff).toBe(index);
+ expect(index.snapshotDiff).toBeInstanceOf(Function);
expect(index.toMatchDiffSnapshot).toBeInstanceOf(Function);
expect(index.getSnapshotDiffSerializer).toBeInstanceOf(Function);
const {
- snapshotDiff,
toMatchDiffSnapshot,
getSnapshotDiffSerializer,
- } = require('../src/index');
+ } = require('../build/index');
- expect(snapshotDiff).toBe(index);
expect(toMatchDiffSnapshot).toBe(index.toMatchDiffSnapshot);
expect(getSnapshotDiffSerializer).toBe(index.getSnapshotDiffSerializer);
});
diff --git a/__tests__/setSerializers.test.js b/__tests__/setSerializers.test.js
index bb1ea72..a58fe34 100644
--- a/__tests__/setSerializers.test.js
+++ b/__tests__/setSerializers.test.js
@@ -1,23 +1,22 @@
-// @flow
const React = require('react');
const { configure, shallow: enzymeShallow } = require('enzyme');
const ReactShallowRenderer = require('react-test-renderer/shallow');
const Adapter = require('enzyme-adapter-react-16');
const enzymeToJson = require('enzyme-to-json/serializer');
-const snapshotDiff = require('../src/index');
+const {
+ snapshotDiff,
+ setSerializers,
+ defaultSerializers,
+} = require('../src/index');
configure({ adapter: new Adapter() });
const reactShallow = new ReactShallowRenderer();
-snapshotDiff.setSerializers([...snapshotDiff.defaultSerializers, enzymeToJson]);
-
-type Props = {
- test: string,
-};
+setSerializers([...defaultSerializers, enzymeToJson]);
const Component = ({ value }) =>
I have value {value}
;
-const NestedComponent = (props: Props) => (
+const NestedComponent = (props) => (
Hello World - {props.test}
diff --git a/__tests__/snapshotDiff.test.js b/__tests__/snapshotDiff.test.js
index dde2e1f..0660330 100644
--- a/__tests__/snapshotDiff.test.js
+++ b/__tests__/snapshotDiff.test.js
@@ -1,9 +1,7 @@
-// @flow
-
/* eslint-disable react/no-multi-comp */
const React = require('react');
-const snapshotDiff = require('../src/index');
+const { snapshotDiff } = require('../src/index');
const a = `
some
@@ -78,15 +76,7 @@ const noIndentB = `
@script
`;
-type Props = {
- test?: string,
- unnamedFunction?: () => void,
- unnamedJestMock?: () => void,
- namedJestMock?: () => void,
- withSecond?: boolean,
-};
-
-class Component extends React.Component
{
+class Component extends React.Component {
render() {
return (
@@ -171,7 +161,7 @@ class Component extends React.Component
{
}
}
-class FragmentComponent extends React.Component {
+class FragmentComponent extends React.Component {
render() {
return (
@@ -254,7 +244,6 @@ test('can use stablePatchmarks on diff', () => {
describe('failed optional deps', () => {
beforeEach(() => {
jest.mock('react-test-renderer', () => {
- // $FlowFixMe -- this is intended.
require('non-existent-module-for-testing'); // eslint-disable-line
});
});
diff --git a/__tests__/toMatchDiffSnapshot.test.js b/__tests__/toMatchDiffSnapshot.test.js
index 751188a..4bce615 100644
--- a/__tests__/toMatchDiffSnapshot.test.js
+++ b/__tests__/toMatchDiffSnapshot.test.js
@@ -1,5 +1,3 @@
-// @flow
-
const snapshotDiff = require('../src/index');
const a = `
@@ -35,18 +33,15 @@ beforeAll(() => {
});
test('works with default options', () => {
- // $FlowFixMe
expect(a).toMatchDiffSnapshot(b);
});
-[{ expand: true }, { contextLines: 0 }].forEach((options: any) => {
+[{ expand: true }, { contextLines: 0 }].forEach((options) => {
test(`proxies "${Object.keys(options).join(', ')}" option(s)`, () => {
- // $FlowFixMe
expect(a).toMatchDiffSnapshot(b, options);
});
});
test('works with custom name', () => {
- // $FlowFixMe
expect(a).toMatchDiffSnapshot(b, {}, 'slim');
});
diff --git a/babel.config.js b/babel.config.js
index e7a9fd7..369d9e2 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -1,7 +1,7 @@
module.exports = {
presets: [
'@babel/preset-react',
- '@babel/preset-flow',
+ '@babel/preset-typescript',
['@babel/preset-env', { targets: { node: '12' } }],
],
};
diff --git a/flow-typed/npm/jest_v23.x.x.js b/flow-typed/npm/jest_v23.x.x.js
deleted file mode 100644
index 95835f5..0000000
--- a/flow-typed/npm/jest_v23.x.x.js
+++ /dev/null
@@ -1,1155 +0,0 @@
-// flow-typed signature: 78c200acffbcc16bba9478f5396c3a00
-// flow-typed version: b2980740dd/jest_v23.x.x/flow_>=v0.39.x
-
-type JestMockFn, TReturn> = {
- (...args: TArguments): TReturn,
- /**
- * An object for introspecting mock calls
- */
- mock: {
- /**
- * An array that represents all calls that have been made into this mock
- * function. Each call is represented by an array of arguments that were
- * passed during the call.
- */
- calls: Array,
- /**
- * An array that contains all the object instances that have been
- * instantiated from this mock function.
- */
- instances: Array,
- /**
- * An array that contains all the object results that have been
- * returned by this mock function call
- */
- results: Array<{ isThrow: boolean, value: TReturn }>
- },
- /**
- * Resets all information stored in the mockFn.mock.calls and
- * mockFn.mock.instances arrays. Often this is useful when you want to clean
- * up a mock's usage data between two assertions.
- */
- mockClear(): void,
- /**
- * Resets all information stored in the mock. This is useful when you want to
- * completely restore a mock back to its initial state.
- */
- mockReset(): void,
- /**
- * Removes the mock and restores the initial implementation. This is useful
- * when you want to mock functions in certain test cases and restore the
- * original implementation in others. Beware that mockFn.mockRestore only
- * works when mock was created with jest.spyOn. Thus you have to take care of
- * restoration yourself when manually assigning jest.fn().
- */
- mockRestore(): void,
- /**
- * Accepts a function that should be used as the implementation of the mock.
- * The mock itself will still record all calls that go into and instances
- * that come from itself -- the only difference is that the implementation
- * will also be executed when the mock is called.
- */
- mockImplementation(
- fn: (...args: TArguments) => TReturn
- ): JestMockFn
,
- /**
- * Accepts a function that will be used as an implementation of the mock for
- * one call to the mocked function. Can be chained so that multiple function
- * calls produce different results.
- */
- mockImplementationOnce(
- fn: (...args: TArguments) => TReturn
- ): JestMockFn,
- /**
- * Accepts a string to use in test result output in place of "jest.fn()" to
- * indicate which mock function is being referenced.
- */
- mockName(name: string): JestMockFn,
- /**
- * Just a simple sugar function for returning `this`
- */
- mockReturnThis(): void,
- /**
- * Accepts a value that will be returned whenever the mock function is called.
- */
- mockReturnValue(value: TReturn): JestMockFn,
- /**
- * Sugar for only returning a value once inside your mock
- */
- mockReturnValueOnce(value: TReturn): JestMockFn,
- /**
- * Sugar for jest.fn().mockImplementation(() => Promise.resolve(value))
- */
- mockResolvedValue(value: TReturn): JestMockFn>,
- /**
- * Sugar for jest.fn().mockImplementationOnce(() => Promise.resolve(value))
- */
- mockResolvedValueOnce(value: TReturn): JestMockFn>,
- /**
- * Sugar for jest.fn().mockImplementation(() => Promise.reject(value))
- */
- mockRejectedValue(value: TReturn): JestMockFn>,
- /**
- * Sugar for jest.fn().mockImplementationOnce(() => Promise.reject(value))
- */
- mockRejectedValueOnce(value: TReturn): JestMockFn>
-};
-
-type JestAsymmetricEqualityType = {
- /**
- * A custom Jasmine equality tester
- */
- asymmetricMatch(value: mixed): boolean
-};
-
-type JestCallsType = {
- allArgs(): mixed,
- all(): mixed,
- any(): boolean,
- count(): number,
- first(): mixed,
- mostRecent(): mixed,
- reset(): void
-};
-
-type JestClockType = {
- install(): void,
- mockDate(date: Date): void,
- tick(milliseconds?: number): void,
- uninstall(): void
-};
-
-type JestMatcherResult = {
- message?: string | (() => string),
- pass: boolean
-};
-
-type JestMatcher = (actual: any, expected: any) =>
- | JestMatcherResult
- | Promise;
-
-type JestPromiseType = {
- /**
- * Use rejects to unwrap the reason of a rejected promise so any other
- * matcher can be chained. If the promise is fulfilled the assertion fails.
- */
- rejects: JestExpectType,
- /**
- * Use resolves to unwrap the value of a fulfilled promise so any other
- * matcher can be chained. If the promise is rejected the assertion fails.
- */
- resolves: JestExpectType
-};
-
-/**
- * Jest allows functions and classes to be used as test names in test() and
- * describe()
- */
-type JestTestName = string | Function;
-
-/**
- * Plugin: jest-styled-components
- */
-
-type JestStyledComponentsMatcherValue =
- | string
- | JestAsymmetricEqualityType
- | RegExp
- | typeof undefined;
-
-type JestStyledComponentsMatcherOptions = {
- media?: string;
- modifier?: string;
- supports?: string;
-}
-
-type JestStyledComponentsMatchersType = {
- toHaveStyleRule(
- property: string,
- value: JestStyledComponentsMatcherValue,
- options?: JestStyledComponentsMatcherOptions
- ): void,
-};
-
-/**
- * Plugin: jest-enzyme
- */
-type EnzymeMatchersType = {
- // 5.x
- toBeEmpty(): void,
- toBePresent(): void,
- // 6.x
- toBeChecked(): void,
- toBeDisabled(): void,
- toBeEmptyRender(): void,
- toContainMatchingElement(selector: string): void;
- toContainMatchingElements(n: number, selector: string): void;
- toContainExactlyOneMatchingElement(selector: string): void;
- toContainReact(element: React$Element): void,
- toExist(): void,
- toHaveClassName(className: string): void,
- toHaveHTML(html: string): void,
- toHaveProp: ((propKey: string, propValue?: any) => void) & ((props: Object) => void),
- toHaveRef(refName: string): void,
- toHaveState: ((stateKey: string, stateValue?: any) => void) & ((state: Object) => void),
- toHaveStyle: ((styleKey: string, styleValue?: any) => void) & ((style: Object) => void),
- toHaveTagName(tagName: string): void,
- toHaveText(text: string): void,
- toHaveValue(value: any): void,
- toIncludeText(text: string): void,
- toMatchElement(
- element: React$Element,
- options?: {| ignoreProps?: boolean, verbose?: boolean |},
- ): void,
- toMatchSelector(selector: string): void,
- // 7.x
- toHaveDisplayName(name: string): void,
-};
-
-// DOM testing library extensions https://github.com/kentcdodds/dom-testing-library#custom-jest-matchers
-type DomTestingLibraryType = {
- toBeDisabled(): void,
- toBeEmpty(): void,
- toBeInTheDocument(): void,
- toBeVisible(): void,
- toContainElement(element: HTMLElement | null): void,
- toContainHTML(htmlText: string): void,
- toHaveAttribute(name: string, expectedValue?: string): void,
- toHaveClass(...classNames: string[]): void,
- toHaveFocus(): void,
- toHaveFormValues(expectedValues: { [name: string]: any }): void,
- toHaveStyle(css: string): void,
- toHaveTextContent(content: string | RegExp, options?: { normalizeWhitespace: boolean }): void,
- toBeInTheDOM(): void,
-};
-
-// Jest JQuery Matchers: https://github.com/unindented/custom-jquery-matchers
-type JestJQueryMatchersType = {
- toExist(): void,
- toHaveLength(len: number): void,
- toHaveId(id: string): void,
- toHaveClass(className: string): void,
- toHaveTag(tag: string): void,
- toHaveAttr(key: string, val?: any): void,
- toHaveProp(key: string, val?: any): void,
- toHaveText(text: string | RegExp): void,
- toHaveData(key: string, val?: any): void,
- toHaveValue(val: any): void,
- toHaveCss(css: {[key: string]: any}): void,
- toBeChecked(): void,
- toBeDisabled(): void,
- toBeEmpty(): void,
- toBeHidden(): void,
- toBeSelected(): void,
- toBeVisible(): void,
- toBeFocused(): void,
- toBeInDom(): void,
- toBeMatchedBy(sel: string): void,
- toHaveDescendant(sel: string): void,
- toHaveDescendantWithText(sel: string, text: string | RegExp): void
-};
-
-
-// Jest Extended Matchers: https://github.com/jest-community/jest-extended
-type JestExtendedMatchersType = {
- /**
- * Note: Currently unimplemented
- * Passing assertion
- *
- * @param {String} message
- */
- // pass(message: string): void;
-
- /**
- * Note: Currently unimplemented
- * Failing assertion
- *
- * @param {String} message
- */
- // fail(message: string): void;
-
- /**
- * Use .toBeEmpty when checking if a String '', Array [] or Object {} is empty.
- */
- toBeEmpty(): void;
-
- /**
- * Use .toBeOneOf when checking if a value is a member of a given Array.
- * @param {Array.<*>} members
- */
- toBeOneOf(members: any[]): void;
-
- /**
- * Use `.toBeNil` when checking a value is `null` or `undefined`.
- */
- toBeNil(): void;
-
- /**
- * Use `.toSatisfy` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean`.
- * @param {Function} predicate
- */
- toSatisfy(predicate: (n: any) => boolean): void;
-
- /**
- * Use `.toBeArray` when checking if a value is an `Array`.
- */
- toBeArray(): void;
-
- /**
- * Use `.toBeArrayOfSize` when checking if a value is an `Array` of size x.
- * @param {Number} x
- */
- toBeArrayOfSize(x: number): void;
-
- /**
- * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set.
- * @param {Array.<*>} members
- */
- toIncludeAllMembers(members: any[]): void;
-
- /**
- * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set.
- * @param {Array.<*>} members
- */
- toIncludeAnyMembers(members: any[]): void;
-
- /**
- * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array.
- * @param {Function} predicate
- */
- toSatisfyAll(predicate: (n: any) => boolean): void;
-
- /**
- * Use `.toBeBoolean` when checking if a value is a `Boolean`.
- */
- toBeBoolean(): void;
-
- /**
- * Use `.toBeTrue` when checking a value is equal (===) to `true`.
- */
- toBeTrue(): void;
-
- /**
- * Use `.toBeFalse` when checking a value is equal (===) to `false`.
- */
- toBeFalse(): void;
-
- /**
- * Use .toBeDate when checking if a value is a Date.
- */
- toBeDate(): void;
-
- /**
- * Use `.toBeFunction` when checking if a value is a `Function`.
- */
- toBeFunction(): void;
-
- /**
- * Use `.toHaveBeenCalledBefore` when checking if a `Mock` was called before another `Mock`.
- *
- * Note: Required Jest version>22
- * Note: Your mock functions will have to be asynchronous to cause the timestamps inside of Jest to occur in a differentJS event loop, otherwise the mock timestamps will all be the same
- *
- * @param {Mock} mock
- */
- toHaveBeenCalledBefore(mock: JestMockFn): void;
-
- /**
- * Use `.toBeNumber` when checking if a value is a `Number`.
- */
- toBeNumber(): void;
-
- /**
- * Use `.toBeNaN` when checking a value is `NaN`.
- */
- toBeNaN(): void;
-
- /**
- * Use `.toBeFinite` when checking if a value is a `Number`, not `NaN` or `Infinity`.
- */
- toBeFinite(): void;
-
- /**
- * Use `.toBePositive` when checking if a value is a positive `Number`.
- */
- toBePositive(): void;
-
- /**
- * Use `.toBeNegative` when checking if a value is a negative `Number`.
- */
- toBeNegative(): void;
-
- /**
- * Use `.toBeEven` when checking if a value is an even `Number`.
- */
- toBeEven(): void;
-
- /**
- * Use `.toBeOdd` when checking if a value is an odd `Number`.
- */
- toBeOdd(): void;
-
- /**
- * Use `.toBeWithin` when checking if a number is in between the given bounds of: start (inclusive) and end (exclusive).
- *
- * @param {Number} start
- * @param {Number} end
- */
- toBeWithin(start: number, end: number): void;
-
- /**
- * Use `.toBeObject` when checking if a value is an `Object`.
- */
- toBeObject(): void;
-
- /**
- * Use `.toContainKey` when checking if an object contains the provided key.
- *
- * @param {String} key
- */
- toContainKey(key: string): void;
-
- /**
- * Use `.toContainKeys` when checking if an object has all of the provided keys.
- *
- * @param {Array.} keys
- */
- toContainKeys(keys: string[]): void;
-
- /**
- * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys.
- *
- * @param {Array.} keys
- */
- toContainAllKeys(keys: string[]): void;
-
- /**
- * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys.
- *
- * @param {Array.} keys
- */
- toContainAnyKeys(keys: string[]): void;
-
- /**
- * Use `.toContainValue` when checking if an object contains the provided value.
- *
- * @param {*} value
- */
- toContainValue(value: any): void;
-
- /**
- * Use `.toContainValues` when checking if an object contains all of the provided values.
- *
- * @param {Array.<*>} values
- */
- toContainValues(values: any[]): void;
-
- /**
- * Use `.toContainAllValues` when checking if an object only contains all of the provided values.
- *
- * @param {Array.<*>} values
- */
- toContainAllValues(values: any[]): void;
-
- /**
- * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values.
- *
- * @param {Array.<*>} values
- */
- toContainAnyValues(values: any[]): void;
-
- /**
- * Use `.toContainEntry` when checking if an object contains the provided entry.
- *
- * @param {Array.} entry
- */
- toContainEntry(entry: [string, string]): void;
-
- /**
- * Use `.toContainEntries` when checking if an object contains all of the provided entries.
- *
- * @param {Array.>} entries
- */
- toContainEntries(entries: [string, string][]): void;
-
- /**
- * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries.
- *
- * @param {Array.>} entries
- */
- toContainAllEntries(entries: [string, string][]): void;
-
- /**
- * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries.
- *
- * @param {Array.>} entries
- */
- toContainAnyEntries(entries: [string, string][]): void;
-
- /**
- * Use `.toBeExtensible` when checking if an object is extensible.
- */
- toBeExtensible(): void;
-
- /**
- * Use `.toBeFrozen` when checking if an object is frozen.
- */
- toBeFrozen(): void;
-
- /**
- * Use `.toBeSealed` when checking if an object is sealed.
- */
- toBeSealed(): void;
-
- /**
- * Use `.toBeString` when checking if a value is a `String`.
- */
- toBeString(): void;
-
- /**
- * Use `.toEqualCaseInsensitive` when checking if a string is equal (===) to another ignoring the casing of both strings.
- *
- * @param {String} string
- */
- toEqualCaseInsensitive(string: string): void;
-
- /**
- * Use `.toStartWith` when checking if a `String` starts with a given `String` prefix.
- *
- * @param {String} prefix
- */
- toStartWith(prefix: string): void;
-
- /**
- * Use `.toEndWith` when checking if a `String` ends with a given `String` suffix.
- *
- * @param {String} suffix
- */
- toEndWith(suffix: string): void;
-
- /**
- * Use `.toInclude` when checking if a `String` includes the given `String` substring.
- *
- * @param {String} substring
- */
- toInclude(substring: string): void;
-
- /**
- * Use `.toIncludeRepeated` when checking if a `String` includes the given `String` substring the correct number of times.
- *
- * @param {String} substring
- * @param {Number} times
- */
- toIncludeRepeated(substring: string, times: number): void;
-
- /**
- * Use `.toIncludeMultiple` when checking if a `String` includes all of the given substrings.
- *
- * @param {Array.} substring
- */
- toIncludeMultiple(substring: string[]): void;
-};
-
-interface JestExpectType {
- not:
- & JestExpectType
- & EnzymeMatchersType
- & DomTestingLibraryType
- & JestJQueryMatchersType
- & JestStyledComponentsMatchersType
- & JestExtendedMatchersType,
- /**
- * If you have a mock function, you can use .lastCalledWith to test what
- * arguments it was last called with.
- */
- lastCalledWith(...args: Array): void,
- /**
- * toBe just checks that a value is what you expect. It uses === to check
- * strict equality.
- */
- toBe(value: any): void,
- /**
- * Use .toBeCalledWith to ensure that a mock function was called with
- * specific arguments.
- */
- toBeCalledWith(...args: Array): void,
- /**
- * Using exact equality with floating point numbers is a bad idea. Rounding
- * means that intuitive things fail.
- */
- toBeCloseTo(num: number, delta: any): void,
- /**
- * Use .toBeDefined to check that a variable is not undefined.
- */
- toBeDefined(): void,
- /**
- * Use .toBeFalsy when you don't care what a value is, you just want to
- * ensure a value is false in a boolean context.
- */
- toBeFalsy(): void,
- /**
- * To compare floating point numbers, you can use toBeGreaterThan.
- */
- toBeGreaterThan(number: number): void,
- /**
- * To compare floating point numbers, you can use toBeGreaterThanOrEqual.
- */
- toBeGreaterThanOrEqual(number: number): void,
- /**
- * To compare floating point numbers, you can use toBeLessThan.
- */
- toBeLessThan(number: number): void,
- /**
- * To compare floating point numbers, you can use toBeLessThanOrEqual.
- */
- toBeLessThanOrEqual(number: number): void,
- /**
- * Use .toBeInstanceOf(Class) to check that an object is an instance of a
- * class.
- */
- toBeInstanceOf(cls: Class<*>): void,
- /**
- * .toBeNull() is the same as .toBe(null) but the error messages are a bit
- * nicer.
- */
- toBeNull(): void,
- /**
- * Use .toBeTruthy when you don't care what a value is, you just want to
- * ensure a value is true in a boolean context.
- */
- toBeTruthy(): void,
- /**
- * Use .toBeUndefined to check that a variable is undefined.
- */
- toBeUndefined(): void,
- /**
- * Use .toContain when you want to check that an item is in a list. For
- * testing the items in the list, this uses ===, a strict equality check.
- */
- toContain(item: any): void,
- /**
- * Use .toContainEqual when you want to check that an item is in a list. For
- * testing the items in the list, this matcher recursively checks the
- * equality of all fields, rather than checking for object identity.
- */
- toContainEqual(item: any): void,
- /**
- * Use .toEqual when you want to check that two objects have the same value.
- * This matcher recursively checks the equality of all fields, rather than
- * checking for object identity.
- */
- toEqual(value: any): void,
- /**
- * Use .toHaveBeenCalled to ensure that a mock function got called.
- */
- toHaveBeenCalled(): void,
- toBeCalled(): void;
- /**
- * Use .toHaveBeenCalledTimes to ensure that a mock function got called exact
- * number of times.
- */
- toHaveBeenCalledTimes(number: number): void,
- toBeCalledTimes(number: number): void;
- /**
- *
- */
- toHaveBeenNthCalledWith(nthCall: number, ...args: Array): void;
- nthCalledWith(nthCall: number, ...args: Array): void;
- /**
- *
- */
- toHaveReturned(): void;
- toReturn(): void;
- /**
- *
- */
- toHaveReturnedTimes(number: number): void;
- toReturnTimes(number: number): void;
- /**
- *
- */
- toHaveReturnedWith(value: any): void;
- toReturnWith(value: any): void;
- /**
- *
- */
- toHaveLastReturnedWith(value: any): void;
- lastReturnedWith(value: any): void;
- /**
- *
- */
- toHaveNthReturnedWith(nthCall: number, value: any): void;
- nthReturnedWith(nthCall: number, value: any): void;
- /**
- * Use .toHaveBeenCalledWith to ensure that a mock function was called with
- * specific arguments.
- */
- toHaveBeenCalledWith(...args: Array): void,
- toBeCalledWith(...args: Array): void,
- /**
- * Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
- * with specific arguments.
- */
- toHaveBeenLastCalledWith(...args: Array): void,
- lastCalledWith(...args: Array): void,
- /**
- * Check that an object has a .length property and it is set to a certain
- * numeric value.
- */
- toHaveLength(number: number): void,
- /**
- *
- */
- toHaveProperty(propPath: string, value?: any): void,
- /**
- * Use .toMatch to check that a string matches a regular expression or string.
- */
- toMatch(regexpOrString: RegExp | string): void,
- /**
- * Use .toMatchObject to check that a javascript object matches a subset of the properties of an object.
- */
- toMatchObject(object: Object | Array): void,
- /**
- * Use .toStrictEqual to check that a javascript object matches a subset of the properties of an object.
- */
- toStrictEqual(value: any): void,
- /**
- * This ensures that an Object matches the most recent snapshot.
- */
- toMatchSnapshot(propertyMatchers?: any, name?: string): void,
- /**
- * This ensures that an Object matches the most recent snapshot.
- */
- toMatchSnapshot(name: string): void,
-
- toMatchInlineSnapshot(snapshot?: string): void,
- toMatchInlineSnapshot(propertyMatchers?: any, snapshot?: string): void,
- /**
- * Use .toThrow to test that a function throws when it is called.
- * If you want to test that a specific error gets thrown, you can provide an
- * argument to toThrow. The argument can be a string for the error message,
- * a class for the error, or a regex that should match the error.
- *
- * Alias: .toThrowError
- */
- toThrow(message?: string | Error | Class | RegExp): void,
- toThrowError(message?: string | Error | Class | RegExp): void,
- /**
- * Use .toThrowErrorMatchingSnapshot to test that a function throws a error
- * matching the most recent snapshot when it is called.
- */
- toThrowErrorMatchingSnapshot(): void,
- toThrowErrorMatchingInlineSnapshot(snapshot?: string): void,
-}
-
-type JestObjectType = {
- /**
- * Disables automatic mocking in the module loader.
- *
- * After this method is called, all `require()`s will return the real
- * versions of each module (rather than a mocked version).
- */
- disableAutomock(): JestObjectType,
- /**
- * An un-hoisted version of disableAutomock
- */
- autoMockOff(): JestObjectType,
- /**
- * Enables automatic mocking in the module loader.
- */
- enableAutomock(): JestObjectType,
- /**
- * An un-hoisted version of enableAutomock
- */
- autoMockOn(): JestObjectType,
- /**
- * Clears the mock.calls and mock.instances properties of all mocks.
- * Equivalent to calling .mockClear() on every mocked function.
- */
- clearAllMocks(): JestObjectType,
- /**
- * Resets the state of all mocks. Equivalent to calling .mockReset() on every
- * mocked function.
- */
- resetAllMocks(): JestObjectType,
- /**
- * Restores all mocks back to their original value.
- */
- restoreAllMocks(): JestObjectType,
- /**
- * Removes any pending timers from the timer system.
- */
- clearAllTimers(): void,
- /**
- * The same as `mock` but not moved to the top of the expectation by
- * babel-jest.
- */
- doMock(moduleName: string, moduleFactory?: any): JestObjectType,
- /**
- * The same as `unmock` but not moved to the top of the expectation by
- * babel-jest.
- */
- dontMock(moduleName: string): JestObjectType,
- /**
- * Returns a new, unused mock function. Optionally takes a mock
- * implementation.
- */
- fn, TReturn>(
- implementation?: (...args: TArguments) => TReturn
- ): JestMockFn,
- /**
- * Determines if the given function is a mocked function.
- */
- isMockFunction(fn: Function): boolean,
- /**
- * Given the name of a module, use the automatic mocking system to generate a
- * mocked version of the module for you.
- */
- genMockFromModule(moduleName: string): any,
- /**
- * Mocks a module with an auto-mocked version when it is being required.
- *
- * The second argument can be used to specify an explicit module factory that
- * is being run instead of using Jest's automocking feature.
- *
- * The third argument can be used to create virtual mocks -- mocks of modules
- * that don't exist anywhere in the system.
- */
- mock(
- moduleName: string,
- moduleFactory?: any,
- options?: Object
- ): JestObjectType,
- /**
- * Returns the actual module instead of a mock, bypassing all checks on
- * whether the module should receive a mock implementation or not.
- */
- requireActual(moduleName: string): any,
- /**
- * Returns a mock module instead of the actual module, bypassing all checks
- * on whether the module should be required normally or not.
- */
- requireMock(moduleName: string): any,
- /**
- * Resets the module registry - the cache of all required modules. This is
- * useful to isolate modules where local state might conflict between tests.
- */
- resetModules(): JestObjectType,
- /**
- * Exhausts the micro-task queue (usually interfaced in node via
- * process.nextTick).
- */
- runAllTicks(): void,
- /**
- * Exhausts the macro-task queue (i.e., all tasks queued by setTimeout(),
- * setInterval(), and setImmediate()).
- */
- runAllTimers(): void,
- /**
- * Exhausts all tasks queued by setImmediate().
- */
- runAllImmediates(): void,
- /**
- * Executes only the macro task queue (i.e. all tasks queued by setTimeout()
- * or setInterval() and setImmediate()).
- */
- advanceTimersByTime(msToRun: number): void,
- /**
- * Executes only the macro task queue (i.e. all tasks queued by setTimeout()
- * or setInterval() and setImmediate()).
- *
- * Renamed to `advanceTimersByTime`.
- */
- runTimersToTime(msToRun: number): void,
- /**
- * Executes only the macro-tasks that are currently pending (i.e., only the
- * tasks that have been queued by setTimeout() or setInterval() up to this
- * point)
- */
- runOnlyPendingTimers(): void,
- /**
- * Explicitly supplies the mock object that the module system should return
- * for the specified module. Note: It is recommended to use jest.mock()
- * instead.
- */
- setMock(moduleName: string, moduleExports: any): JestObjectType,
- /**
- * Indicates that the module system should never return a mocked version of
- * the specified module from require() (e.g. that it should always return the
- * real module).
- */
- unmock(moduleName: string): JestObjectType,
- /**
- * Instructs Jest to use fake versions of the standard timer functions
- * (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
- * setImmediate and clearImmediate).
- */
- useFakeTimers(): JestObjectType,
- /**
- * Instructs Jest to use the real versions of the standard timer functions.
- */
- useRealTimers(): JestObjectType,
- /**
- * Creates a mock function similar to jest.fn but also tracks calls to
- * object[methodName].
- */
- spyOn(object: Object, methodName: string, accessType?: "get" | "set"): JestMockFn,
- /**
- * Set the default timeout interval for tests and before/after hooks in milliseconds.
- * Note: The default timeout interval is 5 seconds if this method is not called.
- */
- setTimeout(timeout: number): JestObjectType
-};
-
-type JestSpyType = {
- calls: JestCallsType
-};
-
-/** Runs this function after every test inside this context */
-declare function afterEach(
- fn: (done: () => void) => ?Promise,
- timeout?: number
-): void;
-/** Runs this function before every test inside this context */
-declare function beforeEach(
- fn: (done: () => void) => ?Promise,
- timeout?: number
-): void;
-/** Runs this function after all tests have finished inside this context */
-declare function afterAll(
- fn: (done: () => void) => ?Promise,
- timeout?: number
-): void;
-/** Runs this function before any tests have started inside this context */
-declare function beforeAll(
- fn: (done: () => void) => ?Promise,
- timeout?: number
-): void;
-
-/** A context for grouping tests together */
-declare var describe: {
- /**
- * Creates a block that groups together several related tests in one "test suite"
- */
- (name: JestTestName, fn: () => void): void,
-
- /**
- * Only run this describe block
- */
- only(name: JestTestName, fn: () => void): void,
-
- /**
- * Skip running this describe block
- */
- skip(name: JestTestName, fn: () => void): void,
-
- /**
- * each runs this test against array of argument arrays per each run
- *
- * @param {table} table of Test
- */
- each(
- ...table: Array | mixed> | [Array, string]
- ): (
- name: JestTestName,
- fn?: (...args: Array) => ?Promise,
- timeout?: number
- ) => void,
-};
-
-/** An individual test unit */
-declare var it: {
- /**
- * An individual test unit
- *
- * @param {JestTestName} Name of Test
- * @param {Function} Test
- * @param {number} Timeout for the test, in milliseconds.
- */
- (
- name: JestTestName,
- fn?: (done: () => void) => ?Promise,
- timeout?: number
- ): void,
-
- /**
- * Only run this test
- *
- * @param {JestTestName} Name of Test
- * @param {Function} Test
- * @param {number} Timeout for the test, in milliseconds.
- */
- only(
- name: JestTestName,
- fn?: (done: () => void) => ?Promise,
- timeout?: number
- ): {
- each(
- ...table: Array | mixed> | [Array, string]
- ): (
- name: JestTestName,
- fn?: (...args: Array) => ?Promise,
- timeout?: number
- ) => void,
- },
-
- /**
- * Skip running this test
- *
- * @param {JestTestName} Name of Test
- * @param {Function} Test
- * @param {number} Timeout for the test, in milliseconds.
- */
- skip(
- name: JestTestName,
- fn?: (done: () => void) => ?Promise,
- timeout?: number
- ): void,
-
- /**
- * Run the test concurrently
- *
- * @param {JestTestName} Name of Test
- * @param {Function} Test
- * @param {number} Timeout for the test, in milliseconds.
- */
- concurrent(
- name: JestTestName,
- fn?: (done: () => void) => ?Promise,
- timeout?: number
- ): void,
-
- /**
- * each runs this test against array of argument arrays per each run
- *
- * @param {table} table of Test
- */
- each(
- ...table: Array | mixed> | [Array, string]
- ): (
- name: JestTestName,
- fn?: (...args: Array) => ?Promise,
- timeout?: number
- ) => void,
-};
-
-declare function fit(
- name: JestTestName,
- fn: (done: () => void) => ?Promise,
- timeout?: number
-): void;
-/** An individual test unit */
-declare var test: typeof it;
-/** A disabled group of tests */
-declare var xdescribe: typeof describe;
-/** A focused group of tests */
-declare var fdescribe: typeof describe;
-/** A disabled individual test */
-declare var xit: typeof it;
-/** A disabled individual test */
-declare var xtest: typeof it;
-
-type JestPrettyFormatColors = {
- comment: { close: string, open: string },
- content: { close: string, open: string },
- prop: { close: string, open: string },
- tag: { close: string, open: string },
- value: { close: string, open: string },
-};
-
-type JestPrettyFormatIndent = string => string;
-type JestPrettyFormatRefs = Array;
-type JestPrettyFormatPrint = any => string;
-type JestPrettyFormatStringOrNull = string | null;
-
-type JestPrettyFormatOptions = {|
- callToJSON: boolean,
- edgeSpacing: string,
- escapeRegex: boolean,
- highlight: boolean,
- indent: number,
- maxDepth: number,
- min: boolean,
- plugins: JestPrettyFormatPlugins,
- printFunctionName: boolean,
- spacing: string,
- theme: {|
- comment: string,
- content: string,
- prop: string,
- tag: string,
- value: string,
- |},
-|};
-
-type JestPrettyFormatPlugin = {
- print: (
- val: any,
- serialize: JestPrettyFormatPrint,
- indent: JestPrettyFormatIndent,
- opts: JestPrettyFormatOptions,
- colors: JestPrettyFormatColors,
- ) => string,
- test: any => boolean,
-};
-
-type JestPrettyFormatPlugins = Array;
-
-/** The expect function is used every time you want to test a value */
-declare var expect: {
- /** The object that you want to make assertions against */
- (value: any):
- & JestExpectType
- & JestPromiseType
- & EnzymeMatchersType
- & DomTestingLibraryType
- & JestJQueryMatchersType
- & JestStyledComponentsMatchersType
- & JestExtendedMatchersType,
-
- /** Add additional Jasmine matchers to Jest's roster */
- extend(matchers: { [name: string]: JestMatcher }): void,
- /** Add a module that formats application-specific data structures. */
- addSnapshotSerializer(pluginModule: JestPrettyFormatPlugin): void,
- assertions(expectedAssertions: number): void,
- hasAssertions(): void,
- any(value: mixed): JestAsymmetricEqualityType,
- anything(): any,
- arrayContaining(value: Array): Array,
- objectContaining(value: Object): Object,
- /** Matches any received string that contains the exact expected string. */
- stringContaining(value: string): string,
- stringMatching(value: string | RegExp): string,
- not: {
- arrayContaining: (value: $ReadOnlyArray) => Array,
- objectContaining: (value: {}) => Object,
- stringContaining: (value: string) => string,
- stringMatching: (value: string | RegExp) => string,
- },
-};
-
-// TODO handle return type
-// http://jasmine.github.io/2.4/introduction.html#section-Spies
-declare function spyOn(value: mixed, method: string): Object;
-
-/** Holds all functions related to manipulating test runner */
-declare var jest: JestObjectType;
-
-/**
- * The global Jasmine object, this is generally not exposed as the public API,
- * using features inside here could break in later versions of Jest.
- */
-declare var jasmine: {
- DEFAULT_TIMEOUT_INTERVAL: number,
- any(value: mixed): JestAsymmetricEqualityType,
- anything(): any,
- arrayContaining(value: Array): Array,
- clock(): JestClockType,
- createSpy(name: string): JestSpyType,
- createSpyObj(
- baseName: string,
- methodNames: Array
- ): { [methodName: string]: JestSpyType },
- objectContaining(value: Object): Object,
- stringMatching(value: string): string
-};
diff --git a/index.d.ts b/index.d.ts
index 98f68c5..86b2ab1 100644
--- a/index.d.ts
+++ b/index.d.ts
@@ -1,60 +1,24 @@
///
-type DiffOptions = {
- expand?: boolean;
- colors?: boolean;
- contextLines?: number;
- stablePatchmarks?: boolean;
- aAnnotation?: string;
- bAnnotation?: string;
-};
+import type { Options } from './build';
+
+export {
+ defaultSerializers,
+ setSerializers,
+ getSnapshotDiffSerializer,
+ toMatchDiffSnapshot,
+ snapshotDiff,
+} from './build';
+
+export type { DiffSerializer, Options } from './build';
declare namespace jest {
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Matchers {
/**
* Compare the difference between the actual in the `expect()`
* vs the object inside `valueB` with some extra options.
*/
- toMatchDiffSnapshot(
- valueB: any,
- options?: DiffOptions,
- testName?: string
- ): R;
- }
-}
-
-interface Serializer {
- test: (value: any) => boolean;
- print: (value: any, _serializer?: any) => any;
- diffOptions?: (valueA: any, valueB: any) => DiffOptions;
-}
-
-declare module 'snapshot-diff' {
- interface SnapshotDiff {
- /**
- * Compare the changes from a, to b
- */
- (a: any, b: any, options?: DiffOptions): string;
- /**
- * Allows you to pull out toMatchDiffSnapshot and
- * make it available via `expect.extend({ toMatchDiffSnapshot })`.
- */
- toMatchDiffSnapshot: jest.CustomMatcher;
- /**
- * By default Jest adds extra quotes around strings so it makes diff
- * snapshots of objects too noisy. To fix this – snapshot-diff comes
- * with custom serializer.
- */
- getSnapshotDiffSerializer: () => jest.SnapshotSerializerPlugin;
- /**
- * Add new serializers for unsupported data types, or to set a different
- * serializer for React components. If you want to keep the default React
- * serializer in place, don't forget to add the default serializers to your
- * list of serializers.
- */
- setSerializers: (serializers: Array) => void;
- defaultSerializers: Array;
+ toMatchDiffSnapshot(valueB: any, options?: Options, testName?: string): R;
}
- const diff: SnapshotDiff;
- export = diff;
}
diff --git a/package.json b/package.json
index d8ad9a7..9d60237 100644
--- a/package.json
+++ b/package.json
@@ -3,16 +3,17 @@
"version": "0.9.0",
"description": "Diffing Jest snapshots utility",
"main": "build/index.js",
- "typings": "index.d.ts",
+ "types": "build/index.d.ts",
"license": "MIT",
"author": "Michał Pierzchała ",
"scripts": {
- "build": "babel src --out-dir build",
- "lint": "eslint . --ext js --cache",
- "typecheck": "flow check",
- "prepublish": "npm run build",
+ "babel-build": "babel --extensions .ts src --out-dir build",
+ "build": "yarn babel-build && yarn typecheck",
+ "lint": "eslint . --ext js --ext ts --cache",
+ "typecheck": "tsc -b .",
+ "prepublish": "yarn build",
"test": "jest",
- "watch": "babel -w src --out-dir build"
+ "watch": "yarn babel-build --watch"
},
"repository": "https://github.com/thymikee/snapshot-diff",
"engines": {
@@ -30,17 +31,20 @@
"@babel/cli": "^7.7.0",
"@babel/core": "^7.7.2",
"@babel/preset-env": "^7.7.1",
- "@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.7.0",
+ "@babel/preset-typescript": "^7.0.0",
"@callstack/eslint-config": "^12.0.0",
+ "@tsconfig/node12": "^1.0.11",
+ "@types/jest": "^28.1.8",
+ "@types/react-test-renderer": "^16.9.5",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"enzyme-to-json": "^3.4.0",
"eslint": "^7.0.0",
- "flow-bin": "^0.129.0",
"jest": "^29.0.0",
"react": "^16.13.1",
"react-dom": "16.14.0",
- "react-test-renderer": "^16.13.1"
+ "react-test-renderer": "^16.13.1",
+ "typescript": "^4.7.4"
}
}
diff --git a/src/index.js b/src/index.ts
similarity index 56%
rename from src/index.js
rename to src/index.ts
index a32a213..cb05e17 100644
--- a/src/index.js
+++ b/src/index.ts
@@ -1,21 +1,16 @@
-// @flow
+import { diff } from 'jest-diff';
+import type { MatcherState } from 'expect';
+import { toMatchSnapshot } from 'jest-snapshot';
+import { reactSerializer } from './react-serializer';
+import type { DiffOptions, DiffSerializer } from './types';
-'use strict';
+export type { DiffSerializer } from './types';
-const { diff } = require('jest-diff');
-const snapshot = require('jest-snapshot');
-const reactSerializer = require('./react-serializer');
-
-type Options = {|
- expand?: boolean,
- colors?: boolean,
- contextLines?: number,
- stablePatchmarks?: boolean,
- aAnnotation?: string,
- bAnnotation?: string,
-|};
+export interface Options extends DiffOptions {
+ colors?: boolean;
+}
-const defaultOptions = {
+const defaultOptions: Options = {
expand: false,
colors: false,
contextLines: -1, // Forces to use default from Jest
@@ -26,12 +21,16 @@ const defaultOptions = {
const SNAPSHOT_TITLE = 'Snapshot Diff:\n';
-const identity = (value) => value;
-const defaultSerializers = [reactSerializer];
+const identity = (value: T): T => value;
+export const defaultSerializers = [reactSerializer];
let serializers = defaultSerializers;
-const snapshotDiff = (valueA: any, valueB: any, options?: Options): string => {
- let difference;
+export const snapshotDiff = (
+ valueA: unknown,
+ valueB: unknown,
+ options?: Options
+): string => {
+ let difference: string | null;
const mergedOptions = { ...defaultOptions, ...options };
const matchingSerializer = serializers.find(
@@ -40,9 +39,8 @@ const snapshotDiff = (valueA: any, valueB: any, options?: Options): string => {
if (matchingSerializer) {
const { print, diffOptions } = matchingSerializer;
- const serializerOptions = diffOptions
- ? diffOptions(valueA, valueB) || undefined
- : undefined;
+ const serializerOptions = diffOptions?.(valueA, valueB) || undefined;
+ // @ts-expect-error
difference = diffStrings(print(valueA, identity), print(valueB, identity), {
...mergedOptions,
...serializerOptions,
@@ -51,7 +49,7 @@ const snapshotDiff = (valueA: any, valueB: any, options?: Options): string => {
difference = diffStrings(valueA, valueB, mergedOptions);
}
- if (mergedOptions.stablePatchmarks && !mergedOptions.expand) {
+ if (difference && mergedOptions.stablePatchmarks && !mergedOptions.expand) {
difference = difference.replace(
/^@@ -[0-9]+,[0-9]+ \+[0-9]+,[0-9]+ @@$/gm,
'@@ --- --- @@'
@@ -70,7 +68,7 @@ const noDiffColors = {
patchColor: identity,
};
-function diffStrings(valueA: any, valueB: any, options: Options) {
+function diffStrings(valueA: unknown, valueB: unknown, options: Options) {
return diff(valueA, valueB, {
expand: options.expand,
contextLines: options.contextLines,
@@ -80,18 +78,20 @@ function diffStrings(valueA: any, valueB: any, options: Options) {
});
}
-function toMatchDiffSnapshot(
- valueA: any,
- valueB: any,
+export function toMatchDiffSnapshot(
+ this: MatcherState,
+ valueA: unknown,
+ valueB: unknown,
options?: Options,
- testName?: string
+ ...rest: unknown[]
) {
const difference = snapshotDiff(valueA, valueB, options);
- return snapshot.toMatchSnapshot.call(this, difference, testName || '');
+ // @ts-expect-error
+ return toMatchSnapshot.call(this, difference, ...rest);
}
-function getSnapshotDiffSerializer() {
+export function getSnapshotDiffSerializer() {
return {
test(value: any) {
return typeof value === 'string' && value.indexOf(SNAPSHOT_TITLE) === 0;
@@ -102,13 +102,6 @@ function getSnapshotDiffSerializer() {
};
}
-function setSerializers(customSerializers) {
+export function setSerializers(customSerializers: Array) {
serializers = customSerializers;
}
-
-module.exports = snapshotDiff;
-module.exports.snapshotDiff = snapshotDiff;
-module.exports.toMatchDiffSnapshot = toMatchDiffSnapshot;
-module.exports.getSnapshotDiffSerializer = getSnapshotDiffSerializer;
-module.exports.setSerializers = setSerializers;
-module.exports.defaultSerializers = defaultSerializers;
diff --git a/src/react-serializer.js b/src/react-serializer.ts
similarity index 60%
rename from src/react-serializer.js
rename to src/react-serializer.ts
index 8b76763..ab244fc 100644
--- a/src/react-serializer.js
+++ b/src/react-serializer.ts
@@ -1,19 +1,16 @@
-// @flow
+import { format as prettyFormat, OptionsReceived } from 'pretty-format';
+import { getSerializers } from 'jest-snapshot';
+import type { DiffSerializer } from './types';
-'use strict';
-
-const prettyFormat = require('pretty-format').default;
-const snapshot = require('jest-snapshot');
-
-const serializers = snapshot.getSerializers();
+const serializers = getSerializers();
const reactElement = Symbol.for('react.element');
function getReactComponentSerializer() {
- let renderer;
+ let renderer: typeof import('react-test-renderer');
try {
renderer = require('react-test-renderer'); // eslint-disable-line import/no-extraneous-dependencies
- } catch (error) {
+ } catch (error: any) {
if (error.code === 'MODULE_NOT_FOUND') {
throw new Error(
`Failed to load optional module "react-test-renderer". ` +
@@ -24,23 +21,24 @@ function getReactComponentSerializer() {
}
throw error;
}
- return (value) =>
+ return (value: any) =>
prettyFormat(renderer.create(value), { plugins: serializers });
}
-const reactSerializer = {
- test: (value: any) => value && value.$$typeof === reactElement,
- print: (value: any, _serializer?: (any) => any) => {
+export const reactSerializer: DiffSerializer = {
+ test: (value) => value && value.$$typeof === reactElement,
+ print: (value: any) => {
const reactComponentSerializer = getReactComponentSerializer();
return reactComponentSerializer(value);
},
- diffOptions: (valueA: any, valueB: any) => {
- const prettyFormatOptions = { plugins: serializers, min: true };
+ diffOptions: (valueA, valueB) => {
+ const prettyFormatOptions: OptionsReceived = {
+ plugins: serializers,
+ min: true,
+ };
return {
aAnnotation: prettyFormat(valueA, prettyFormatOptions),
bAnnotation: prettyFormat(valueB, prettyFormatOptions),
};
},
};
-
-module.exports = reactSerializer;
diff --git a/src/types.ts b/src/types.ts
new file mode 100644
index 0000000..194d5b4
--- /dev/null
+++ b/src/types.ts
@@ -0,0 +1,10 @@
+import type { OldPlugin } from 'pretty-format';
+import type { DiffOptions as UpstreamDiffOptions } from 'jest-diff';
+
+export interface DiffOptions extends UpstreamDiffOptions {
+ stablePatchmarks?: boolean;
+}
+
+export interface DiffSerializer extends OldPlugin {
+ diffOptions?: (valueA: unknown, valueB: unknown) => DiffOptions;
+}
diff --git a/tsconfig.json b/tsconfig.json
new file mode 100644
index 0000000..8f94367
--- /dev/null
+++ b/tsconfig.json
@@ -0,0 +1,26 @@
+{
+ "extends": "@tsconfig/node12/tsconfig.json",
+ "compilerOptions": {
+ "rootDir": "src",
+ "outDir": "build",
+ "declaration": true,
+ "emitDeclarationOnly": true,
+ "importsNotUsedAsValues": "error",
+ "stripInternal": true,
+ "strict": true,
+ /* Additional Checks */
+ "noUnusedLocals": true,
+ "noUnusedParameters": true,
+ "noImplicitOverride": true,
+ "noImplicitReturns": true,
+ "noFallthroughCasesInSwitch": true,
+ /* Module Resolution Options */
+ "moduleResolution": "node",
+ /* This needs to be false so our types are possible to consume without setting this */
+ "esModuleInterop": false,
+ "isolatedModules": true,
+ "skipLibCheck": false,
+ "resolveJsonModule": true
+ },
+ "include": ["./src/**/*"]
+}
diff --git a/yarn.lock b/yarn.lock
index bf1ca9e..cda56e0 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -109,10 +109,10 @@
browserslist "^4.20.2"
semver "^6.3.0"
-"@babel/helper-create-class-features-plugin@^7.18.6":
- version "7.18.13"
- resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.13.tgz#63e771187bd06d234f95fdf8bd5f8b6429de6298"
- integrity sha512-hDvXp+QYxSRL+23mpAlSGxHMDyIGChm0/AwTfTAAK5Ufe40nCsyNdaYCGuK91phn/fVu9kqayImRDkvNAgdrsA==
+"@babel/helper-create-class-features-plugin@^7.18.6", "@babel/helper-create-class-features-plugin@^7.18.9":
+ version "7.18.9"
+ resolved "https://registry.yarnpkg.com/@babel/helper-create-class-features-plugin/-/helper-create-class-features-plugin-7.18.9.tgz#d802ee16a64a9e824fcbf0a2ffc92f19d58550ce"
+ integrity sha512-WvypNAYaVh23QcjpMR24CwZY2Nz6hqdOcFdPbNpV56hL5H6KiFheO7Xm1aPdlLQ7d5emYZX7VZwPp9x3z+2opw==
dependencies:
"@babel/helper-annotate-as-pure" "^7.18.6"
"@babel/helper-environment-visitor" "^7.18.9"
@@ -486,13 +486,6 @@
dependencies:
"@babel/helper-plugin-utils" "^7.8.3"
-"@babel/plugin-syntax-flow@^7.18.6":
- version "7.18.6"
- resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-flow/-/plugin-syntax-flow-7.18.6.tgz#774d825256f2379d06139be0c723c4dd444f3ca1"
- integrity sha512-LUbR+KNTBWCUAqRG9ex5Gnzu2IOkt8jRJbHHXFT9q+L9zm7M/QQbEqXyw1n1pohYvOyWC8CjeyjrSaIwiYjK7A==
- dependencies:
- "@babel/helper-plugin-utils" "^7.18.6"
-
"@babel/plugin-syntax-import-assertions@^7.18.6":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-import-assertions/-/plugin-syntax-import-assertions-7.18.6.tgz#cd6190500a4fa2fe31990a963ffab4b63e4505e4"
@@ -577,7 +570,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.14.5"
-"@babel/plugin-syntax-typescript@^7.7.2":
+"@babel/plugin-syntax-typescript@^7.18.6", "@babel/plugin-syntax-typescript@^7.7.2":
version "7.18.6"
resolved "https://registry.yarnpkg.com/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz#1c09cd25795c7c2b8a4ba9ae49394576d4133285"
integrity sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA==
@@ -665,14 +658,6 @@
"@babel/helper-builder-binary-assignment-operator-visitor" "^7.18.6"
"@babel/helper-plugin-utils" "^7.18.6"
-"@babel/plugin-transform-flow-strip-types@^7.18.6":
- version "7.18.9"
- resolved "https://registry.yarnpkg.com/@babel/plugin-transform-flow-strip-types/-/plugin-transform-flow-strip-types-7.18.9.tgz#5b4cc521426263b5ce08893a2db41097ceba35bf"
- integrity sha512-+G6rp2zRuOAInY5wcggsx4+QVao1qPM0osC9fTUVlAV3zOrzTCnrMAFVnR6+a3T8wz1wFIH7KhYMcMB3u1n80A==
- dependencies:
- "@babel/helper-plugin-utils" "^7.18.9"
- "@babel/plugin-syntax-flow" "^7.18.6"
-
"@babel/plugin-transform-for-of@^7.18.8":
version "7.18.8"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-for-of/-/plugin-transform-for-of-7.18.8.tgz#6ef8a50b244eb6a0bdbad0c7c61877e4e30097c1"
@@ -862,6 +847,15 @@
dependencies:
"@babel/helper-plugin-utils" "^7.18.9"
+"@babel/plugin-transform-typescript@^7.18.6":
+ version "7.18.12"
+ resolved "https://registry.yarnpkg.com/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.18.12.tgz#712e9a71b9e00fde9f8c0238e0cceee86ab2f8fd"
+ integrity sha512-2vjjam0cum0miPkenUbQswKowuxs/NjMwIKEq0zwegRxXk12C9YOF9STXnaUptITOtOJHKHpzvvWYOjbm6tc0w==
+ dependencies:
+ "@babel/helper-create-class-features-plugin" "^7.18.9"
+ "@babel/helper-plugin-utils" "^7.18.9"
+ "@babel/plugin-syntax-typescript" "^7.18.6"
+
"@babel/plugin-transform-unicode-escapes@^7.18.10":
version "7.18.10"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-unicode-escapes/-/plugin-transform-unicode-escapes-7.18.10.tgz#1ecfb0eda83d09bbcb77c09970c2dd55832aa246"
@@ -958,15 +952,6 @@
core-js-compat "^3.22.1"
semver "^6.3.0"
-"@babel/preset-flow@^7.0.0":
- version "7.18.6"
- resolved "https://registry.yarnpkg.com/@babel/preset-flow/-/preset-flow-7.18.6.tgz#83f7602ba566e72a9918beefafef8ef16d2810cb"
- integrity sha512-E7BDhL64W6OUqpuyHnSroLnqyRTcG6ZdOBl1OKI/QK/HJfplqK/S3sq1Cckx7oTodJ5yOXyfw7rEADJ6UjoQDQ==
- dependencies:
- "@babel/helper-plugin-utils" "^7.18.6"
- "@babel/helper-validator-option" "^7.18.6"
- "@babel/plugin-transform-flow-strip-types" "^7.18.6"
-
"@babel/preset-modules@^0.1.5":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@babel/preset-modules/-/preset-modules-0.1.5.tgz#ef939d6e7f268827e1841638dc6ff95515e115d9"
@@ -990,6 +975,15 @@
"@babel/plugin-transform-react-jsx-development" "^7.18.6"
"@babel/plugin-transform-react-pure-annotations" "^7.18.6"
+"@babel/preset-typescript@^7.0.0":
+ version "7.18.6"
+ resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.18.6.tgz#ce64be3e63eddc44240c6358daefac17b3186399"
+ integrity sha512-s9ik86kXBAnD760aybBucdpnLsAt0jK1xqJn2juOn9lkOvSHV60os5hxoVJsPzMQxvnUJFAlkont2DvvaYEBtQ==
+ dependencies:
+ "@babel/helper-plugin-utils" "^7.18.6"
+ "@babel/helper-validator-option" "^7.18.6"
+ "@babel/plugin-transform-typescript" "^7.18.6"
+
"@babel/runtime@^7.15.4", "@babel/runtime@^7.8.4":
version "7.18.9"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.18.9.tgz#b4fcfce55db3d2e5e080d2490f608a3b9f407f4a"
@@ -1159,6 +1153,13 @@
"@types/node" "*"
jest-mock "^29.0.0"
+"@jest/expect-utils@^28.1.3":
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-28.1.3.tgz#58561ce5db7cd253a7edddbc051fb39dda50f525"
+ integrity sha512-wvbi9LUrHJLn3NlDW6wF2hvIMtd4JUl2QNVrjq+IBSHirgfrR3o9RnVtxzdEGO2n9JyIWwHnLfby5KzqBGg2YA==
+ dependencies:
+ jest-get-type "^28.0.2"
+
"@jest/expect-utils@^29.0.0":
version "29.0.0"
resolved "https://registry.yarnpkg.com/@jest/expect-utils/-/expect-utils-29.0.0.tgz#aa3a2cbe4630ac2095cd2bcd3040fe42015fe9ed"
@@ -1227,6 +1228,13 @@
terminal-link "^2.0.0"
v8-to-istanbul "^9.0.1"
+"@jest/schemas@^28.1.3":
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-28.1.3.tgz#ad8b86a66f11f33619e3d7e1dcddd7f2d40ff905"
+ integrity sha512-/l/VWsdt/aBXgjshLWOFyFt3IVdYypu5y2Wn2rOO1un6nkqIn8SLXzgIMYXFyYsRWDyF5EthmKJMIdJvk08grg==
+ dependencies:
+ "@sinclair/typebox" "^0.24.1"
+
"@jest/schemas@^29.0.0":
version "29.0.0"
resolved "https://registry.yarnpkg.com/@jest/schemas/-/schemas-29.0.0.tgz#5f47f5994dd4ef067fb7b4188ceac45f77fe952a"
@@ -1284,6 +1292,18 @@
slash "^3.0.0"
write-file-atomic "^4.0.1"
+"@jest/types@^28.1.3":
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/@jest/types/-/types-28.1.3.tgz#b05de80996ff12512bc5ceb1d208285a7d11748b"
+ integrity sha512-RyjiyMUZrKz/c+zlMFO1pm70DcIlST8AeWTkoUdZevew44wcNZQHsEVOiCVtgVnlFFD82FPaXycys58cf2muVQ==
+ dependencies:
+ "@jest/schemas" "^28.1.3"
+ "@types/istanbul-lib-coverage" "^2.0.0"
+ "@types/istanbul-reports" "^3.0.0"
+ "@types/node" "*"
+ "@types/yargs" "^17.0.8"
+ chalk "^4.0.0"
+
"@jest/types@^29.0.0":
version "29.0.0"
resolved "https://registry.yarnpkg.com/@jest/types/-/types-29.0.0.tgz#16bef8898fec32c2c5c17a6eb770539986322587"
@@ -1381,6 +1401,11 @@
dependencies:
"@sinonjs/commons" "^1.7.0"
+"@tsconfig/node12@^1.0.11":
+ version "1.0.11"
+ resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d"
+ integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==
+
"@types/babel__core@^7.1.14":
version "7.1.19"
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.19.tgz#7b497495b7d1b4812bdb9d02804d0576f43ee460"
@@ -1447,6 +1472,14 @@
dependencies:
"@types/istanbul-lib-report" "*"
+"@types/jest@^28.1.8":
+ version "28.1.8"
+ resolved "https://registry.yarnpkg.com/@types/jest/-/jest-28.1.8.tgz#6936409f3c9724ea431efd412ea0238a0f03b09b"
+ integrity sha512-8TJkV++s7B6XqnDrzR1m/TT0A0h948Pnl/097veySPN67VRAgQ4gZ7n2KfJo2rVq6njQjdxU3GCCyDvAeuHoiw==
+ dependencies:
+ expect "^28.0.0"
+ pretty-format "^28.0.0"
+
"@types/json-schema@^7.0.9":
version "7.0.11"
resolved "https://registry.yarnpkg.com/@types/json-schema/-/json-schema-7.0.11.tgz#d421b6c527a3037f7c84433fd2c4229e016863d3"
@@ -1467,6 +1500,32 @@
resolved "https://registry.yarnpkg.com/@types/prettier/-/prettier-2.7.0.tgz#ea03e9f0376a4446f44797ca19d9c46c36e352dc"
integrity sha512-RI1L7N4JnW5gQw2spvL7Sllfuf1SaHdrZpCHiBlCXjIlufi1SMNnbu2teze3/QE67Fg2tBlH7W+mi4hVNk4p0A==
+"@types/prop-types@*":
+ version "15.7.5"
+ resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.5.tgz#5f19d2b85a98e9558036f6a3cacc8819420f05cf"
+ integrity sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==
+
+"@types/react-test-renderer@^16.9.5":
+ version "16.9.5"
+ resolved "https://registry.yarnpkg.com/@types/react-test-renderer/-/react-test-renderer-16.9.5.tgz#edab67da470f7c3e997f58d55dcfe2643cc30a68"
+ integrity sha512-C4cN7C2uSSGOYelp2XfdtJb5TsCP+QiZ+0Bm4U3ZfUswN8oN9O/l86XO/OvBSFCmWY7w75fzsQvZ50eGkFN34A==
+ dependencies:
+ "@types/react" "^16"
+
+"@types/react@^16":
+ version "16.14.30"
+ resolved "https://registry.yarnpkg.com/@types/react/-/react-16.14.30.tgz#a1d83f73f4326798d65fe6b58cb4caeacee47623"
+ integrity sha512-tG+xGtDDSuIl1l63mN0LnaROAc99knkYyN4YTheE80iPzYvSy0U8LVie+OBZkrgjVrpkQV6bMCkSphPBnVNk6g==
+ dependencies:
+ "@types/prop-types" "*"
+ "@types/scheduler" "*"
+ csstype "^3.0.2"
+
+"@types/scheduler@*":
+ version "0.16.2"
+ resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
+ integrity sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew==
+
"@types/stack-utils@^2.0.0":
version "2.0.1"
resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-2.0.1.tgz#20f18294f797f2209b5f65c8e3b5c8e8261d127c"
@@ -1507,15 +1566,23 @@
"@typescript-eslint/utils" "5.35.1"
"@typescript-eslint/parser@^5.4.0":
- version "5.35.1"
- resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.35.1.tgz#bf2ee2ebeaa0a0567213748243fb4eec2857f04f"
- integrity sha512-XL2TBTSrh3yWAsMYpKseBYTVpvudNf69rPOWXWVBI08My2JVT5jR66eTt4IgQFHA/giiKJW5dUD4x/ZviCKyGg==
+ version "5.33.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-5.33.1.tgz#e4b253105b4d2a4362cfaa4e184e2d226c440ff3"
+ integrity sha512-IgLLtW7FOzoDlmaMoXdxG8HOCByTBXrB1V2ZQYSEV1ggMmJfAkMWTwUjjzagS6OkfpySyhKFkBw7A9jYmcHpZA==
dependencies:
- "@typescript-eslint/scope-manager" "5.35.1"
- "@typescript-eslint/types" "5.35.1"
- "@typescript-eslint/typescript-estree" "5.35.1"
+ "@typescript-eslint/scope-manager" "5.33.1"
+ "@typescript-eslint/types" "5.33.1"
+ "@typescript-eslint/typescript-estree" "5.33.1"
debug "^4.3.4"
+"@typescript-eslint/scope-manager@5.33.1":
+ version "5.33.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.33.1.tgz#8d31553e1b874210018ca069b3d192c6d23bc493"
+ integrity sha512-8ibcZSqy4c5m69QpzJn8XQq9NnqAToC8OdH/W6IXPXv83vRyEDPYLdjAlUx8h/rbusq6MkW4YdQzURGOqsn3CA==
+ dependencies:
+ "@typescript-eslint/types" "5.33.1"
+ "@typescript-eslint/visitor-keys" "5.33.1"
+
"@typescript-eslint/scope-manager@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-5.35.1.tgz#ccb69d54b7fd0f2d0226a11a75a8f311f525ff9e"
@@ -1533,11 +1600,29 @@
debug "^4.3.4"
tsutils "^3.21.0"
+"@typescript-eslint/types@5.33.1":
+ version "5.33.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.33.1.tgz#3faef41793d527a519e19ab2747c12d6f3741ff7"
+ integrity sha512-7K6MoQPQh6WVEkMrMW5QOA5FO+BOwzHSNd0j3+BlBwd6vtzfZceJ8xJ7Um2XDi/O3umS8/qDX6jdy2i7CijkwQ==
+
"@typescript-eslint/types@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-5.35.1.tgz#af355fe52a0cc88301e889bc4ada72f279b63d61"
integrity sha512-FDaujtsH07VHzG0gQ6NDkVVhi1+rhq0qEvzHdJAQjysN+LHDCKDKCBRlZFFE0ec0jKxiv0hN63SNfExy0KrbQQ==
+"@typescript-eslint/typescript-estree@5.33.1":
+ version "5.33.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.33.1.tgz#a573bd360790afdcba80844e962d8b2031984f34"
+ integrity sha512-JOAzJ4pJ+tHzA2pgsWQi4804XisPHOtbvwUyqsuuq8+y5B5GMZs7lI1xDWs6V2d7gE/Ez5bTGojSK12+IIPtXA==
+ dependencies:
+ "@typescript-eslint/types" "5.33.1"
+ "@typescript-eslint/visitor-keys" "5.33.1"
+ debug "^4.3.4"
+ globby "^11.1.0"
+ is-glob "^4.0.3"
+ semver "^7.3.7"
+ tsutils "^3.21.0"
+
"@typescript-eslint/typescript-estree@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-5.35.1.tgz#db878a39a0dbdc9bb133f11cdad451770bfba211"
@@ -1563,6 +1648,14 @@
eslint-scope "^5.1.1"
eslint-utils "^3.0.0"
+"@typescript-eslint/visitor-keys@5.33.1":
+ version "5.33.1"
+ resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.33.1.tgz#0155c7571c8cd08956580b880aea327d5c34a18b"
+ integrity sha512-nwIxOK8Z2MPWltLKMLOEZwmfBZReqUdbEoHQXeCpa+sRVARe5twpJGHCB4dk9903Yaf0nMAlGbQfaAH92F60eg==
+ dependencies:
+ "@typescript-eslint/types" "5.33.1"
+ eslint-visitor-keys "^3.3.0"
+
"@typescript-eslint/visitor-keys@5.35.1":
version "5.35.1"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-5.35.1.tgz#285e9e34aed7c876f16ff646a3984010035898e6"
@@ -2075,6 +2168,11 @@ css-what@^6.1.0:
resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4"
integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==
+csstype@^3.0.2:
+ version "3.1.0"
+ resolved "https://registry.yarnpkg.com/csstype/-/csstype-3.1.0.tgz#4ddcac3718d787cf9df0d1b7d15033925c8f29f2"
+ integrity sha512-uX1KG+x9h5hIJsaKR9xHUeUraxf8IODOwq9JLNPq6BwB04a/xgpq3rcx47l5BZu5zBPlgD342tdke3Hom/nJRA==
+
debug@^2.6.9:
version "2.6.9"
resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f"
@@ -2124,6 +2222,11 @@ detect-newline@^3.0.0:
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
integrity sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==
+diff-sequences@^28.1.1:
+ version "28.1.1"
+ resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-28.1.1.tgz#9989dc731266dc2903457a70e996f3a041913ac6"
+ integrity sha512-FU0iFaH/E23a+a718l8Qa/19bF9p06kgE0KipMOMadwa3SjnaElKzPaUC0vnibs6/B/9ni97s61mcejk8W1fQw==
+
diff-sequences@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-29.0.0.tgz#bae49972ef3933556bcb0800b72e8579d19d9e4f"
@@ -2626,6 +2729,17 @@ exit@^0.1.2:
resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c"
integrity sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==
+expect@^28.0.0:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/expect/-/expect-28.1.3.tgz#90a7c1a124f1824133dd4533cce2d2bdcb6603ec"
+ integrity sha512-eEh0xn8HlsuOBxFgIss+2mX85VAS4Qy3OSkjV7rlBWljtA4oWH37glVGyOZSZvErDT/yBywZdPGwCXuTvSG85g==
+ dependencies:
+ "@jest/expect-utils" "^28.1.3"
+ jest-get-type "^28.0.2"
+ jest-matcher-utils "^28.1.3"
+ jest-message-util "^28.1.3"
+ jest-util "^28.1.3"
+
expect@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/expect/-/expect-29.0.0.tgz#e4af58cf4343683ffeca875d75d5c790f2712565"
@@ -2717,11 +2831,6 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787"
integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==
-flow-bin@^0.129.0:
- version "0.129.0"
- resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.129.0.tgz#50294d6e335dd97d095c27b096ea0b94c2415d55"
- integrity sha512-WLXOj09oCK6nODVKM5uxvAzBpxXeI304E60tELMeQd/TJsyfbykNCZ+e4xml9eUOyoac9nDL3YrJpPZMzq0tMA==
-
fs-readdir-recursive@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz#e32fc030a2ccee44a6b5371308da54be0b397d27"
@@ -3226,6 +3335,16 @@ jest-config@^29.0.0:
slash "^3.0.0"
strip-json-comments "^3.1.1"
+jest-diff@^28.1.3:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-28.1.3.tgz#948a192d86f4e7a64c5264ad4da4877133d8792f"
+ integrity sha512-8RqP1B/OXzjjTWkqMX67iqgwBVJRgCyKD3L9nq+6ZqJMdvjE8RgHktqZ6jNrkdMT+dJuYNI3rhQpxaz7drJHfw==
+ dependencies:
+ chalk "^4.0.0"
+ diff-sequences "^28.1.1"
+ jest-get-type "^28.0.2"
+ pretty-format "^28.1.3"
+
jest-diff@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-29.0.0.tgz#24a3dd5846ae0e48cba0194b1397178b06b123ad"
@@ -3266,6 +3385,11 @@ jest-environment-node@^29.0.0:
jest-mock "^29.0.0"
jest-util "^29.0.0"
+jest-get-type@^28.0.2:
+ version "28.0.2"
+ resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-28.0.2.tgz#34622e628e4fdcd793d46db8a242227901fcf203"
+ integrity sha512-ioj2w9/DxSYHfOm5lJKCdcAmPJzQXmbM/Url3rhlghrPvT3tt+7a/+oXc9azkKmLvoiXjtV83bEWqi+vs5nlPA==
+
jest-get-type@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-29.0.0.tgz#843f6c50a1b778f7325df1129a0fd7aa713aef80"
@@ -3298,6 +3422,16 @@ jest-leak-detector@^29.0.0:
jest-get-type "^29.0.0"
pretty-format "^29.0.0"
+jest-matcher-utils@^28.1.3:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-28.1.3.tgz#5a77f1c129dd5ba3b4d7fc20728806c78893146e"
+ integrity sha512-kQeJ7qHemKfbzKoGjHHrRKH6atgxMk8Enkk2iPQ3XwO6oE/KYD8lMYOziCkeSB9G4adPM4nR1DE8Tf5JeWH6Bw==
+ dependencies:
+ chalk "^4.0.0"
+ jest-diff "^28.1.3"
+ jest-get-type "^28.0.2"
+ pretty-format "^28.1.3"
+
jest-matcher-utils@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-29.0.0.tgz#7e79d5d43ccbe4fe2b27f812986f196e7a98746c"
@@ -3308,6 +3442,21 @@ jest-matcher-utils@^29.0.0:
jest-get-type "^29.0.0"
pretty-format "^29.0.0"
+jest-message-util@^28.1.3:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-28.1.3.tgz#232def7f2e333f1eecc90649b5b94b0055e7c43d"
+ integrity sha512-PFdn9Iewbt575zKPf1286Ht9EPoJmYT7P0kY+RibeYZ2XtOr53pDLEFoTWXbd1h4JiGiWpTBC84fc8xMXQMb7g==
+ dependencies:
+ "@babel/code-frame" "^7.12.13"
+ "@jest/types" "^28.1.3"
+ "@types/stack-utils" "^2.0.0"
+ chalk "^4.0.0"
+ graceful-fs "^4.2.9"
+ micromatch "^4.0.4"
+ pretty-format "^28.1.3"
+ slash "^3.0.0"
+ stack-utils "^2.0.3"
+
jest-message-util@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-29.0.0.tgz#7995991fca9b41dc8410d0952894bbd4c5052ba8"
@@ -3449,6 +3598,18 @@ jest-snapshot@^29.0.0:
pretty-format "^29.0.0"
semver "^7.3.5"
+jest-util@^28.1.3:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-28.1.3.tgz#f4f932aa0074f0679943220ff9cbba7e497028b0"
+ integrity sha512-XdqfpHwpcSRko/C35uLYFM2emRAltIIKZiJ9eAmhjsj0CqZMa0p1ib0R5fWIqGhn1a103DebTbpqIaP1qCQ6tQ==
+ dependencies:
+ "@jest/types" "^28.1.3"
+ "@types/node" "*"
+ chalk "^4.0.0"
+ ci-info "^3.2.0"
+ graceful-fs "^4.2.9"
+ picomatch "^2.2.3"
+
jest-util@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-29.0.0.tgz#54dfddf25fb011a2ff93fe8d11738dee8ff7f663"
@@ -3995,6 +4156,16 @@ prettier@^2.4.1:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64"
integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==
+pretty-format@^28.0.0, pretty-format@^28.1.3:
+ version "28.1.3"
+ resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-28.1.3.tgz#c9fba8cedf99ce50963a11b27d982a9ae90970d5"
+ integrity sha512-8gFb/To0OmxHR9+ZTb14Df2vNxdGCX8g1xWGUTqUw5TiZvcQf5sHKObd5UcPyLLyowNwDAMTF3XWOG1B6mxl1Q==
+ dependencies:
+ "@jest/schemas" "^28.1.3"
+ ansi-regex "^5.0.1"
+ ansi-styles "^5.0.0"
+ react-is "^18.0.0"
+
pretty-format@^29.0.0:
version "29.0.0"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-29.0.0.tgz#a9a604ca71678f803f34f6563a25a638fce267ba"
@@ -4588,6 +4759,11 @@ type-fest@^0.21.3:
resolved "https://registry.yarnpkg.com/type-fest/-/type-fest-0.21.3.tgz#d260a24b0198436e133fa26a524a6d65fa3b2e37"
integrity sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==
+typescript@^4.7.4:
+ version "4.7.4"
+ resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
+ integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==
+
unbox-primitive@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/unbox-primitive/-/unbox-primitive-1.0.2.tgz#29032021057d5e6cdbd08c5129c226dff8ed6f9e"