@testing-library/react-native 12.4.3 → 12.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -12
- package/build/act.d.ts +1 -1
- package/build/act.js.map +1 -1
- package/build/fire-event.js.map +1 -1
- package/build/helpers/accessiblity.js.map +1 -1
- package/build/helpers/component-tree.js.map +1 -1
- package/build/helpers/debug-deep.js.map +1 -1
- package/build/helpers/debug-shallow.js.map +1 -1
- package/build/helpers/deprecation.js.map +1 -1
- package/build/helpers/errors.js.map +1 -1
- package/build/helpers/find-all.js.map +1 -1
- package/build/helpers/format-default.js.map +1 -1
- package/build/helpers/format.js.map +1 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-state.js +1 -0
- package/build/helpers/matchers/match-accessibility-state.js.map +1 -1
- package/build/helpers/matchers/match-accessibility-value.js.map +1 -1
- package/build/helpers/matchers/match-array-prop.js.map +1 -1
- package/build/helpers/matchers/match-label-text.js.map +1 -1
- package/build/helpers/matchers/match-object-prop.js.map +1 -1
- package/build/helpers/matchers/match-string-prop.js.map +1 -1
- package/build/helpers/matchers/match-text-content.js.map +1 -1
- package/build/helpers/pointer-events.js.map +1 -1
- package/build/helpers/string-validation.js.map +1 -1
- package/build/helpers/text-content.js.map +1 -1
- package/build/helpers/text-input.js.map +1 -1
- package/build/helpers/timers.js.map +1 -1
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.flow.js +41 -149
- package/build/matchers/to-be-busy.js.map +1 -1
- package/build/matchers/to-be-checked.js.map +1 -1
- package/build/matchers/to-be-collapsed.js.map +1 -1
- package/build/matchers/to-be-disabled.js.map +1 -1
- package/build/matchers/to-be-empty-element.js.map +1 -1
- package/build/matchers/to-be-expanded.js.map +1 -1
- package/build/matchers/to-be-on-the-screen.js.map +1 -1
- package/build/matchers/to-be-partially-checked.js.map +1 -1
- package/build/matchers/to-be-selected.js.map +1 -1
- package/build/matchers/to-be-visible.js.map +1 -1
- package/build/matchers/to-contain-element.js.map +1 -1
- package/build/matchers/to-have-accessibility-value.js.map +1 -1
- package/build/matchers/to-have-accessible-name.js.map +1 -1
- package/build/matchers/to-have-display-value.js.map +1 -1
- package/build/matchers/to-have-prop.js.map +1 -1
- package/build/matchers/to-have-style.js.map +1 -1
- package/build/matchers/to-have-text-content.js.map +1 -1
- package/build/matchers/types.js.map +1 -1
- package/build/matchers/utils.js.map +1 -1
- package/build/matches.js.map +1 -1
- package/build/pure.d.ts +1 -1
- package/build/pure.js.map +1 -1
- package/build/queries/accessibility-state.js.map +1 -1
- package/build/queries/accessibility-value.js.map +1 -1
- package/build/queries/display-value.js.map +1 -1
- package/build/queries/hint-text.js.map +1 -1
- package/build/queries/label-text.js.map +1 -1
- package/build/queries/make-queries.js +3 -0
- package/build/queries/make-queries.js.map +1 -1
- package/build/queries/placeholder-text.js.map +1 -1
- package/build/queries/role.js.map +1 -1
- package/build/queries/test-id.js.map +1 -1
- package/build/queries/text.js.map +1 -1
- package/build/queries/unsafe-props.js.map +1 -1
- package/build/queries/unsafe-type.js.map +1 -1
- package/build/react-versions.js.map +1 -1
- package/build/render-act.d.ts +0 -1
- package/build/render-act.js.map +1 -1
- package/build/render-hook.js.map +1 -1
- package/build/render.js.map +1 -1
- package/build/screen.d.ts +6 -2
- package/build/screen.js +3 -2
- package/build/screen.js.map +1 -1
- package/build/shallow.js.map +1 -1
- package/build/user-event/clear.js.map +1 -1
- package/build/user-event/event-builder/common.d.ts +6 -7
- package/build/user-event/event-builder/common.js +2 -2
- package/build/user-event/event-builder/common.js.map +1 -1
- package/build/user-event/event-builder/index.d.ts +6 -7
- package/build/user-event/event-builder/scroll-view.js.map +1 -1
- package/build/user-event/press/press.js.map +1 -1
- package/build/user-event/scroll/scroll-to.js.map +1 -1
- package/build/user-event/scroll/state.js.map +1 -1
- package/build/user-event/scroll/utils.js.map +1 -1
- package/build/user-event/setup/setup.js.map +1 -1
- package/build/user-event/type/type.js.map +1 -1
- package/build/user-event/utils/dispatch-event.js.map +1 -1
- package/build/user-event/utils/wait.js.map +1 -1
- package/build/user-event/utils/warn-about-real-timers.js +3 -0
- package/build/user-event/utils/warn-about-real-timers.js.map +1 -1
- package/build/wait-for-element-to-be-removed.js.map +1 -1
- package/build/wait-for.js.map +1 -1
- package/package.json +13 -13
- package/typings/index.flow.js +41 -149
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type.js","names":["_hostComponentNames","require","_eventBuilder","_errors","_textInput","_pointerEvents","_utils","_parseKeys","type","element","text","options","isHostTextInput","ErrorWithStack","isTextInputEditable","isPointerEventEnabled","keys","parseKeys","skipPress","dispatchEvent","EventBuilder","Common","touch","focus","wait","config","currentText","props","value","defaultValue","key","previousText","applyKey","emitTypingEvents","finalText","submitEditing","TextInput","endEditing","blur","isMultiline","multiline","keyPress","textInput","change","selectionRange","start","length","end","selectionChange","contentSize","getTextContentSize","contentSizeChange","slice"],"sources":["../../../src/user-event/type/type.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from '../../helpers/host-component-names';\nimport { EventBuilder } from '../event-builder';\nimport { ErrorWithStack } from '../../helpers/errors';\nimport { isTextInputEditable } from '../../helpers/text-input';\nimport { isPointerEventEnabled } from '../../helpers/pointer-events';\nimport { UserEventConfig, UserEventInstance } from '../setup';\nimport { dispatchEvent, wait, getTextContentSize } from '../utils';\nimport { parseKeys } from './parse-keys';\n\nexport interface TypeOptions {\n skipPress?: boolean;\n submitEditing?: boolean;\n}\n\nexport async function type(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n options?: TypeOptions
|
|
1
|
+
{"version":3,"file":"type.js","names":["_hostComponentNames","require","_eventBuilder","_errors","_textInput","_pointerEvents","_utils","_parseKeys","type","element","text","options","isHostTextInput","ErrorWithStack","isTextInputEditable","isPointerEventEnabled","keys","parseKeys","skipPress","dispatchEvent","EventBuilder","Common","touch","focus","wait","config","currentText","props","value","defaultValue","key","previousText","applyKey","emitTypingEvents","finalText","submitEditing","TextInput","endEditing","blur","isMultiline","multiline","keyPress","textInput","change","selectionRange","start","length","end","selectionChange","contentSize","getTextContentSize","contentSizeChange","slice"],"sources":["../../../src/user-event/type/type.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { isHostTextInput } from '../../helpers/host-component-names';\nimport { EventBuilder } from '../event-builder';\nimport { ErrorWithStack } from '../../helpers/errors';\nimport { isTextInputEditable } from '../../helpers/text-input';\nimport { isPointerEventEnabled } from '../../helpers/pointer-events';\nimport { UserEventConfig, UserEventInstance } from '../setup';\nimport { dispatchEvent, wait, getTextContentSize } from '../utils';\nimport { parseKeys } from './parse-keys';\n\nexport interface TypeOptions {\n skipPress?: boolean;\n submitEditing?: boolean;\n}\n\nexport async function type(\n this: UserEventInstance,\n element: ReactTestInstance,\n text: string,\n options?: TypeOptions,\n): Promise<void> {\n if (!isHostTextInput(element)) {\n throw new ErrorWithStack(\n `type() works only with host \"TextInput\" elements. Passed element has type \"${element.type}\".`,\n type,\n );\n }\n\n // Skip events if the element is disabled\n if (!isTextInputEditable(element) || !isPointerEventEnabled(element)) {\n return;\n }\n\n const keys = parseKeys(text);\n\n if (!options?.skipPress) {\n dispatchEvent(element, 'pressIn', EventBuilder.Common.touch());\n }\n\n dispatchEvent(element, 'focus', EventBuilder.Common.focus());\n\n if (!options?.skipPress) {\n await wait(this.config);\n dispatchEvent(element, 'pressOut', EventBuilder.Common.touch());\n }\n\n let currentText = element.props.value ?? element.props.defaultValue ?? '';\n for (const key of keys) {\n const previousText = element.props.value ?? currentText;\n currentText = applyKey(previousText, key);\n\n await emitTypingEvents(this.config, element, key, currentText, previousText);\n }\n\n const finalText = element.props.value ?? currentText;\n await wait(this.config);\n\n if (options?.submitEditing) {\n dispatchEvent(element, 'submitEditing', EventBuilder.TextInput.submitEditing(finalText));\n }\n\n dispatchEvent(element, 'endEditing', EventBuilder.TextInput.endEditing(finalText));\n\n dispatchEvent(element, 'blur', EventBuilder.Common.blur());\n}\n\nexport async function emitTypingEvents(\n config: UserEventConfig,\n element: ReactTestInstance,\n key: string,\n currentText: string,\n previousText: string,\n) {\n const isMultiline = element.props.multiline === true;\n\n await wait(config);\n dispatchEvent(element, 'keyPress', EventBuilder.TextInput.keyPress(key));\n\n // According to the docs only multiline TextInput emits textInput event\n // @see: https://github.com/facebook/react-native/blob/42a2898617da1d7a98ef574a5b9e500681c8f738/packages/react-native/Libraries/Components/TextInput/TextInput.d.ts#L754\n if (isMultiline) {\n dispatchEvent(\n element,\n 'textInput',\n EventBuilder.TextInput.textInput(currentText, previousText),\n );\n }\n\n dispatchEvent(element, 'change', EventBuilder.TextInput.change(currentText));\n dispatchEvent(element, 'changeText', currentText);\n\n const selectionRange = {\n start: currentText.length,\n end: currentText.length,\n };\n dispatchEvent(element, 'selectionChange', EventBuilder.TextInput.selectionChange(selectionRange));\n\n // According to the docs only multiline TextInput emits contentSizeChange event\n // @see: https://reactnative.dev/docs/textinput#oncontentsizechange\n if (isMultiline) {\n const contentSize = getTextContentSize(currentText);\n dispatchEvent(\n element,\n 'contentSizeChange',\n EventBuilder.TextInput.contentSizeChange(contentSize),\n );\n }\n}\n\nfunction applyKey(text: string, key: string) {\n if (key === 'Enter') {\n return `${text}\\n`;\n }\n\n if (key === 'Backspace') {\n return text.slice(0, -1);\n }\n\n return text + key;\n}\n"],"mappings":";;;;;;;AACA,IAAAA,mBAAA,GAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AAOO,eAAeO,IAAIA,CAExBC,OAA0B,EAC1BC,IAAY,EACZC,OAAqB,EACN;EACf,IAAI,CAAC,IAAAC,mCAAe,EAACH,OAAO,CAAC,EAAE;IAC7B,MAAM,IAAII,sBA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S,CAACY,eAAe,CAACJ,cAAc,CAAC,CAAC;;EAEjG;EACA;EACA,IAAIL,WAAW,EAAE;IACf,MAAMU,WAAW,GAAG,IAAAC,yBAAkB,EAACxB,WAAW,CAAC;IACnD,IAAAP,oBAAa,EACXV,OAAO,EACP,mBAAmB,EACnBW,0BAAY,CAACgB,SAAS,CAACe,iBAAiB,CAACF,WAAW,CACtD,CAAC;EACH;AACF;AAEA,SAASjB,QAAQA,CAACtB,IAAY,EAAEoB,GAAW,EAAE;EAC3C,IAAIA,GAAG,KAAK,OAAO,EAAE;IACnB,OAAQ,GAAEpB,IAAK,IAAG;EACpB;EAEA,IAAIoB,GAAG,KAAK,WAAW,EAAE;IACvB,OAAOpB,IAAI,CAAC0C,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;EAC1B;EAEA,OAAO1C,IAAI,GAAGoB,GAAG;AACnB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-event.js","names":["_act","_interopRequireDefault","require","obj","__esModule","default","dispatchEvent","element","eventName","event","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(
|
|
1
|
+
{"version":3,"file":"dispatch-event.js","names":["_act","_interopRequireDefault","require","obj","__esModule","default","dispatchEvent","element","eventName","event","handler","getEventHandler","act","handleName","getEventHandlerName","handle","props","undefined","charAt","toUpperCase","slice"],"sources":["../../../src/user-event/utils/dispatch-event.ts"],"sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport act from '../../act';\n\n/**\n * Basic dispatch event function used by User Event module.\n *\n * @param element element trigger event on\n * @param eventName name of the event\n * @param event event payload(s)\n */\nexport function dispatchEvent(element: ReactTestInstance, eventName: string, ...event: unknown[]) {\n const handler = getEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n // This will be called synchronously.\n void act(() => {\n handler(...event);\n });\n}\n\nfunction getEventHandler(element: ReactTestInstance, eventName: string) {\n const handleName = getEventHandlerName(eventName);\n const handle = element.props[handleName] as unknown;\n if (typeof handle !== 'function') {\n return undefined;\n }\n\n return handle;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${eventName.charAt(0).toUpperCase()}${eventName.slice(1)}`;\n}\n"],"mappings":";;;;;;AACA,IAAAA,IAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4B,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAE5B;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,aAAaA,CAACC,OAA0B,EAAEC,SAAiB,EAAE,GAAGC,KAAgB,EAAE;EAChG,MAAMC,OAAO,GAAGC,eAAe,CAACJ,OAAO,EAAEC,SAAS,CAAC;EACnD,IAAI,CAACE,OAAO,EAAE;IACZ;EACF;;EAEA;EACA,KAAK,IAAAE,YAAG,EAAC,MAAM;IACbF,OAAO,CAAC,GAAGD,KAAK,CAAC;EACnB,CAAC,CAAC;AACJ;AAEA,SAASE,eAAeA,CAACJ,OAA0B,EAAEC,SAAiB,EAAE;EACtE,MAAMK,UAAU,GAAGC,mBAAmB,CAACN,SAAS,CAAC;EACjD,MAAMO,MAAM,GAAGR,OAAO,CAACS,KAAK,CAACH,UAAU,CAAY;EACnD,IAAI,OAAOE,MAAM,KAAK,UAAU,EAAE;IAChC,OAAOE,SAAS;EAClB;EAEA,OAAOF,MAAM;AACf;AAEA,SAASD,mBAAmBA,CAACN,SAAiB,EAAE;EAC9C,OAAQ,KAAIA,SAAS,CAACU,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAE,GAAEX,SAAS,CAACY,KAAK,CAAC,CAAC,CAAE,EAAC;AACtE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait.js","names":["wait","config","durationInMs","delay","Promise","all","resolve","globalThis","setTimeout","advanceTimers"],"sources":["../../../src/user-event/utils/wait.ts"],"sourcesContent":["import { UserEventConfig } from '../setup';\n\nexport function wait(config: UserEventConfig, durationInMs?: number) {\n const delay = durationInMs ?? config.delay;\n if (typeof delay !== 'number') {\n return;\n }\n\n return Promise.all([\n new Promise<void>((resolve)
|
|
1
|
+
{"version":3,"file":"wait.js","names":["wait","config","durationInMs","delay","Promise","all","resolve","globalThis","setTimeout","advanceTimers"],"sources":["../../../src/user-event/utils/wait.ts"],"sourcesContent":["import { UserEventConfig } from '../setup';\n\nexport function wait(config: UserEventConfig, durationInMs?: number) {\n const delay = durationInMs ?? config.delay;\n if (typeof delay !== 'number') {\n return;\n }\n\n return Promise.all([\n new Promise<void>((resolve) => globalThis.setTimeout(() => resolve(), delay)),\n config.advanceTimers(delay),\n ]);\n}\n"],"mappings":";;;;;;AAEO,SAASA,IAAIA,CAACC,MAAuB,EAAEC,YAAqB,EAAE;EACnE,MAAMC,KAAK,GAAGD,YAAY,IAAID,MAAM,CAACE,KAAK;EAC1C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7B;EACF;EAEA,OAAOC,OAAO,CAACC,GAAG,CAAC,CACjB,IAAID,OAAO,CAAQE,OAAO,IAAKC,UAAU,CAACC,UAAU,CAAC,MAAMF,OAAO,CAAC,CAAC,EAAEH,KAAK,CAAC,CAAC,EAC7EF,MAAM,CAACQ,aAAa,CAACN,KAAK,CAAC,CAC5B,CAAC;AACJ"}
|
|
@@ -6,6 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.warnAboutRealTimersIfNeeded = void 0;
|
|
7
7
|
var _timers = require("../../helpers/timers");
|
|
8
8
|
const warnAboutRealTimersIfNeeded = () => {
|
|
9
|
+
if (process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
9
12
|
const areFakeTimersEnabled = (0, _timers.jestFakeTimersAreEnabled)();
|
|
10
13
|
if (areFakeTimersEnabled) {
|
|
11
14
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"warn-about-real-timers.js","names":["_timers","require","warnAboutRealTimersIfNeeded","areFakeTimersEnabled","jestFakeTimersAreEnabled","console","warn","exports"],"sources":["../../../src/user-event/utils/warn-about-real-timers.ts"],"sourcesContent":["import { jestFakeTimersAreEnabled } from '../../helpers/timers';\n\nexport const warnAboutRealTimersIfNeeded = () => {\n const areFakeTimersEnabled = jestFakeTimersAreEnabled();\n if (areFakeTimersEnabled) {\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(`It is recommended to use userEvent with fake timers\nSome events involve duration so your tests may take a long time to run.\nFor instance calling userEvent.longPress with real timers will take 500 ms.`);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,2BAA2B,GAAGA,CAAA,KAAM;EAC/C,MAAMC,oBAAoB,GAAG,IAAAC,gCAAwB,EAAC,CAAC;EACvD,IAAID,oBAAoB,EAAE;IACxB;EACF;;EAEA;EACAE,OAAO,CAACC,IAAI,CAAE;AAChB;AACA,4EAA4E,CAAC;AAC7E,CAAC;AAACC,OAAA,
|
|
1
|
+
{"version":3,"file":"warn-about-real-timers.js","names":["_timers","require","warnAboutRealTimersIfNeeded","process","env","RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS","areFakeTimersEnabled","jestFakeTimersAreEnabled","console","warn","exports"],"sources":["../../../src/user-event/utils/warn-about-real-timers.ts"],"sourcesContent":["import { jestFakeTimersAreEnabled } from '../../helpers/timers';\n\nexport const warnAboutRealTimersIfNeeded = () => {\n if (process.env.RNTL_SKIP_AUTO_DETECT_FAKE_TIMERS) {\n return;\n }\n\n const areFakeTimersEnabled = jestFakeTimersAreEnabled();\n if (areFakeTimersEnabled) {\n return;\n }\n\n // eslint-disable-next-line no-console\n console.warn(`It is recommended to use userEvent with fake timers\nSome events involve duration so your tests may take a long time to run.\nFor instance calling userEvent.longPress with real timers will take 500 ms.`);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,MAAMC,2BAA2B,GAAGA,CAAA,KAAM;EAC/C,IAAIC,OAAO,CAACC,GAAG,CAACC,iCAAiC,EAAE;IACjD;EACF;EAEA,MAAMC,oBAAoB,GAAG,IAAAC,gCAAwB,EAAC,CAAC;EACvD,IAAID,oBAAoB,EAAE;IACxB;EACF;;EAEA;EACAE,OAAO,CAACC,IAAI,CAAE;AAChB;AACA,4EAA4E,CAAC;AAC7E,CAAC;AAACC,OAAA,CAAAR,2BAAA,GAAAA,2BAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait-for-element-to-be-removed.js","names":["_waitFor","_interopRequireDefault","require","_errors","obj","__esModule","default","isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor","error"],"sources":["../src/wait-for-element-to-be-removed.ts"],"sourcesContent":["import waitFor from './wait-for';\nimport type { WaitForOptions } from './wait-for';\nimport { ErrorWithStack } from './helpers/errors';\n\nfunction isRemoved<T>(result: T): boolean {\n return !result || (Array.isArray(result) && !result.length);\n}\n\nexport default async function waitForElementToBeRemoved<T>(\n expectation: () => T,\n options?: WaitForOptions
|
|
1
|
+
{"version":3,"file":"wait-for-element-to-be-removed.js","names":["_waitFor","_interopRequireDefault","require","_errors","obj","__esModule","default","isRemoved","result","Array","isArray","length","waitForElementToBeRemoved","expectation","options","timeoutError","ErrorWithStack","initialElements","waitFor","error"],"sources":["../src/wait-for-element-to-be-removed.ts"],"sourcesContent":["import waitFor from './wait-for';\nimport type { WaitForOptions } from './wait-for';\nimport { ErrorWithStack } from './helpers/errors';\n\nfunction isRemoved<T>(result: T): boolean {\n return !result || (Array.isArray(result) && !result.length);\n}\n\nexport default async function waitForElementToBeRemoved<T>(\n expectation: () => T,\n options?: WaitForOptions,\n): Promise<T> {\n // Created here so we get a nice stacktrace\n const timeoutError = new ErrorWithStack(\n 'Timed out in waitForElementToBeRemoved.',\n waitForElementToBeRemoved,\n );\n\n // Elements have to be present initally and then removed.\n const initialElements = expectation();\n if (isRemoved(initialElements)) {\n throw new ErrorWithStack(\n 'The element(s) given to waitForElementToBeRemoved are already removed. waitForElementToBeRemoved requires that the element(s) exist(s) before waiting for removal.',\n waitForElementToBeRemoved,\n );\n }\n\n return await waitFor(() => {\n let result;\n try {\n result = expectation();\n } catch (error) {\n return initialElements;\n }\n\n if (!isRemoved(result)) {\n throw timeoutError;\n }\n\n return initialElements;\n }, options);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,QAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAkD,SAAAD,uBAAAG,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAElD,SAASG,SAASA,CAAIC,MAAS,EAAW;EACxC,OAAO,CAACA,MAAM,IAAKC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,IAAI,CAACA,MAAM,CAACG,MAAO;AAC7D;AAEe,eAAeC,yBAAyBA,CACrDC,WAAoB,EACpBC,OAAwB,EACZ;EACZ;EACA,MAAMC,YAAY,GAAG,IAAIC,sBAAc,CACrC,yCAAyC,EACzCJ,yBACF,CAAC;;EAED;EACA,MAAMK,eAAe,GAAGJ,WAAW,CAAC,CAAC;EACrC,IAAIN,SAAS,CAACU,eAAe,CAAC,EAAE;IAC9B,MAAM,IAAID,sBAAc,CACtB,oKAAoK,EACpKJ,yBACF,CAAC;EACH;EAEA,OAAO,MAAM,IAAAM,gBAAO,EAAC,MAAM;IACzB,IAAIV,MAAM;IACV,IAAI;MACFA,MAAM,GAAGK,WAAW,CAAC,CAAC;IACxB,CAAC,CAAC,OAAOM,KAAK,EAAE;MACd,OAAOF,eAAe;IACxB;IAEA,IAAI,CAACV,SAAS,CAACC,MAAM,CAAC,EAAE;MACtB,MAAMO,YAAY;IACpB;IAEA,OAAOE,eAAe;EACxB,CAAC,EAAEH,OAAO,CAAC;AACb"}
|
package/build/wait-for.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait-for.js","names":["_config","require","_flushMicroTasks","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","usingFakeTimers","jestFakeTimersAreEnabled","checkExpectation","fakeTimeRemaining","error","Error","copyStackTrace","handleTimeout","jest","advanceTimersByTime","flushMicroTasks","setTimeout","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","String","waitFor","options","ErrorWithStack","optionsWithStackTrace","wrapAsync"],"sources":["../src/wait-for.ts"],"sourcesContent":["/* globals jest */\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\nimport { wrapAsync } from './helpers/wrap-async';\n\nconst DEFAULT_INTERVAL = 50;\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: Error) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = getConfig().asyncUtilTimeout,\n interval = DEFAULT_INTERVAL,\n stackTraceError,\n onTimeout,\n }: WaitForOptions\n): Promise<T> {\n if (typeof expectation !== 'function') {\n throw new TypeError('Received `expectation` arg must be a function');\n }\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n let lastError: unknown, intervalId: ReturnType<typeof setTimeout>;\n let finished = false;\n let promiseStatus = 'idle';\n\n let overallTimeoutTimer: NodeJS.Timeout | null = null;\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n // eslint-disable-next-line no-unmodified-loop-condition\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n handleTimeout();\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n // eslint-disable-next-line no-await-in-loop\n await flushMicroTasks();\n }\n } else {\n overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(\n done: { type: 'result'; result: T } | { type: 'error'; error: unknown }\n ) {\n finished = true;\n if (overallTimeoutTimer) {\n clearTimeout(overallTimeoutTimer);\n }\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-ignore result can be a promise\n // eslint-disable-next-line promise/prefer-await-to-then\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as any;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n }\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error: Error;\n if (lastError) {\n if (lastError instanceof Error) {\n error = lastError;\n } else {\n error = new Error(String(lastError));\n }\n\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n } else {\n error = new Error('Timed out in waitFor.');\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n }\n if (typeof onTimeout === 'function') {\n const result = onTimeout(error);\n if (result) {\n error = result;\n }\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default function waitFor<T>(\n expectation: () => T,\n options?: WaitForOptions\n): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n return wrapAsync(() => waitForInternal(expectation, optionsWithStackTrace));\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,UAAA,GAAAJ,OAAA;AATA;;AAWA,MAAMK,gBAAgB,GAAG,EAAE;AAS3B,SAASC,eAAeA,CACtBC,WAAoB,EACpB;EACEC,OAAO,GAAG,IAAAC,iBAAS,EAAC,CAAC,CAACC,gBAAgB;EACtCC,QAAQ,GAAGN,gBAAgB;EAC3BO,eAAe;EACfC;AACc,CAAC,EACL;EACZ,IAAI,OAAON,WAAW,KAAK,UAAU,EAAE;IACrC,MAAM,IAAIO,SAAS,CAAC,+CAA+C,CAAC;EACtE;;EAEA;EACA,OAAO,IAAIC,OAAO,CAAC,OAAOC,OAAO,EAAEC,MAAM,KAAK;IAC5C,IAAIC,SAAkB,EAAEC,UAAyC;IACjE,IAAIC,QAAQ,GAAG,KAAK;IACpB,IAAIC,aAAa,GAAG,MAAM;IAE1B,IAAIC,mBAA0C,GAAG,IAAI;IAErD,MAAMC,eAAe,GAAG,IAAAC,gCAAwB,EAAC,CAAC;IAElD,IAAID,eAAe,EAAE;MACnBE,gBAAgB,CAAC,CAAC;MAClB;MACA;MACA;MACA;MACA;MACA,IAAIC,iBAAiB,GAAGlB,OAAO;MAC/B,OAAO,CAACY,QAAQ,EAAE;QAChB,IAAI,CAAC,IAAAI,gCAAwB,EAAC,CAAC,EAAE;UAC/B,MAAMG,KAAK,GAAG,IAAIC,KAAK,CACpB,kUACH,CAAC;UACD,IAAIhB,eAAe,EAAE;YACnB,IAAAiB,sBAAc,EAACF,KAAK,EAAEf,eAAe,CAAC;UACxC;UACAK,MAAM,CAACU,KAAK,C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,EAAE;QACnC,MAAM6B,MAAM,GAAG7B,SAAS,CAACc,KAAK,CAAC;QAC/B,IAAIe,MAAM,EAAE;UACVf,KAAK,GAAGe,MAAM;QAChB;MACF;MACAL,MAAM,CAAC;QAAEI,IAAI,EAAE,OAAO;QAAEd;MAAM,CAAC,CAAC;IAClC;EACF,CAAC,CAAC;AACJ;AAEe,SAASqB,OAAOA,CAC7BzC,WAAoB,EACpB0C,OAAwB,EACZ;EACZ;EACA,MAAMrC,eAAe,GAAG,IAAIsC,sBAAc,CAAC,mBAAmB,EAAEF,OAAO,CAAC;EACxE,MAAMG,qBAAqB,GAAG;IAAEvC,eAAe;IAAE,GAAGqC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAM9C,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC,CAAC;AAC7E"}
|
|
1
|
+
{"version":3,"file":"wait-for.js","names":["_config","require","_flushMicroTasks","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","usingFakeTimers","jestFakeTimersAreEnabled","checkExpectation","fakeTimeRemaining","error","Error","copyStackTrace","handleTimeout","jest","advanceTimersByTime","flushMicroTasks","setTimeout","setInterval","checkRealTimersCallback","onDone","done","clearTimeout","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","String","waitFor","options","ErrorWithStack","optionsWithStackTrace","wrapAsync"],"sources":["../src/wait-for.ts"],"sourcesContent":["/* globals jest */\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport { setTimeout, clearTimeout, jestFakeTimersAreEnabled } from './helpers/timers';\nimport { wrapAsync } from './helpers/wrap-async';\n\nconst DEFAULT_INTERVAL = 50;\n\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: Error) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = getConfig().asyncUtilTimeout,\n interval = DEFAULT_INTERVAL,\n stackTraceError,\n onTimeout,\n }: WaitForOptions,\n): Promise<T> {\n if (typeof expectation !== 'function') {\n throw new TypeError('Received `expectation` arg must be a function');\n }\n\n // eslint-disable-next-line no-async-promise-executor\n return new Promise(async (resolve, reject) => {\n let lastError: unknown, intervalId: ReturnType<typeof setTimeout>;\n let finished = false;\n let promiseStatus = 'idle';\n\n let overallTimeoutTimer: NodeJS.Timeout | null = null;\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n // eslint-disable-next-line no-unmodified-loop-condition\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n handleTimeout();\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n // eslint-disable-next-line no-await-in-loop\n await flushMicroTasks();\n }\n } else {\n overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(done: { type: 'result'; result: T } | { type: 'error'; error: unknown }) {\n finished = true;\n if (overallTimeoutTimer) {\n clearTimeout(overallTimeoutTimer);\n }\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`,\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-ignore result can be a promise\n // eslint-disable-next-line promise/prefer-await-to-then\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as any;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n },\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error: Error;\n if (lastError) {\n if (lastError instanceof Error) {\n error = lastError;\n } else {\n error = new Error(String(lastError));\n }\n\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n } else {\n error = new Error('Timed out in waitFor.');\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n }\n if (typeof onTimeout === 'function') {\n const result = onTimeout(error);\n if (result) {\n error = result;\n }\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default function waitFor<T>(expectation: () => T, options?: WaitForOptions): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n return wrapAsync(() => waitForInternal(expectation, optionsWithStackTrace));\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,UAAA,GAAAJ,OAAA;AALA;;AAOA,MAAMK,gBAAgB,GAAG,EAAE;AAS3B,SAASC,eAAeA,CACtBC,WAAoB,EACpB;EACEC,OAAO,GAAG,IAAAC,iBAAS,EAAC,CAAC,CAACC,gBAAgB;EACtCC,QAAQ,GAAGN,gBAAgB;EAC3BO,eAAe;EACfC;AACc,CAAC,EACL;EACZ,IAAI,OAAON,WAAW,KAAK,UAAU,EAAE;IACrC,MAAM,IAAIO,SAAS,CAAC,+CAA+C,CAAC;EACtE;;EAEA;EACA,OAAO,IAAIC,OAAO,CAAC,OAAOC,OAAO,EAAEC,MAAM,KAAK;IAC5C,IAAIC,SAAkB,EAAEC,UAAyC;IACjE,IAAIC,QAAQ,GAAG,KAAK;IACpB,IAAIC,aAAa,GAAG,MAAM;IAE1B,IAAIC,mBAA0C,GAAG,IAAI;IAErD,MAAMC,eAAe,GAAG,IAAAC,gCAAwB,EAAC,CAAC;IAElD,IAAID,eAAe,EAAE;MACnBE,gBAAgB,CAAC,CAAC;MAClB;MACA;MACA;MACA;MACA;MACA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ACtC;QAEA,IAAIN,eAAe,EAAE;UACnB,IAAAiB,sBAAc,EAACF,KAAK,EAAEf,eAAe,CAAC;QACxC;MACF,CAAC,MAAM;QACLe,KAAK,GAAG,IAAIC,KAAK,CAAC,uBAAuB,CAAC;QAC1C,IAAIhB,eAAe,EAAE;UACnB,IAAAiB,sBAAc,EAACF,KAAK,EAAEf,eAAe,CAAC;QACxC;MACF;MACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;QACnC,MAAM6B,MAAM,GAAG7B,SAAS,CAACc,KAAK,CAAC;QAC/B,IAAIe,MAAM,EAAE;UACVf,KAAK,GAAGe,MAAM;QAChB;MACF;MACAL,MAAM,CAAC;QAAEI,IAAI,EAAE,OAAO;QAAEd;MAAM,CAAC,CAAC;IAClC;EACF,CAAC,CAAC;AACJ;AAEe,SAASqB,OAAOA,CAAIzC,WAAoB,EAAE0C,OAAwB,EAAc;EAC7F;EACA,MAAMrC,eAAe,GAAG,IAAIsC,sBAAc,CAAC,mBAAmB,EAAEF,OAAO,CAAC;EACxE,MAAMG,qBAAqB,GAAG;IAAEvC,eAAe;IAAE,GAAGqC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAM9C,eAAe,CAACC,WAAW,EAAE4C,qBAAqB,CAAC,CAAC;AAC7E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testing-library/react-native",
|
|
3
|
-
"version": "12.4.
|
|
3
|
+
"version": "12.4.5",
|
|
4
4
|
"description": "Simple and complete React Native testing utilities that encourage good testing practices.",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -69,33 +69,33 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"@babel/cli": "^7.23.
|
|
73
|
-
"@babel/core": "^7.
|
|
72
|
+
"@babel/cli": "^7.23.9",
|
|
73
|
+
"@babel/core": "^7.24.0",
|
|
74
74
|
"@babel/plugin-transform-flow-strip-types": "^7.23.3",
|
|
75
|
-
"@babel/preset-env": "^7.
|
|
76
|
-
"@babel/preset-flow": "^7.
|
|
75
|
+
"@babel/preset-env": "^7.24.0",
|
|
76
|
+
"@babel/preset-flow": "^7.24.0",
|
|
77
77
|
"@babel/preset-react": "^7.23.3",
|
|
78
78
|
"@babel/preset-typescript": "^7.23.3",
|
|
79
79
|
"@callstack/eslint-config": "^14.1.0",
|
|
80
80
|
"@release-it/conventional-changelog": "^8.0.1",
|
|
81
81
|
"@relmify/jest-serializer-strip-ansi": "^1.0.2",
|
|
82
|
-
"@types/jest": "^29.5.
|
|
83
|
-
"@types/react": "^18.2.
|
|
82
|
+
"@types/jest": "^29.5.12",
|
|
83
|
+
"@types/react": "^18.2.65",
|
|
84
84
|
"@types/react-test-renderer": "^18.0.7",
|
|
85
85
|
"babel-jest": "^29.7.0",
|
|
86
|
-
"dedent": "^1.5.1",
|
|
87
86
|
"del-cli": "^5.1.0",
|
|
88
|
-
"eslint": "^8.
|
|
87
|
+
"eslint": "^8.57.0",
|
|
89
88
|
"eslint-plugin-flowtype": "^8.0.3",
|
|
89
|
+
"eslint-plugin-prettier": "^4.2.1",
|
|
90
90
|
"flow-bin": "~0.170.0",
|
|
91
|
-
"flow-copy-source": "^2.0.9",
|
|
92
91
|
"jest": "^29.7.0",
|
|
92
|
+
"prettier": "^2.8.8",
|
|
93
93
|
"react": "18.2.0",
|
|
94
|
-
"react-native": "0.
|
|
94
|
+
"react-native": "0.73.6",
|
|
95
95
|
"react-test-renderer": "18.2.0",
|
|
96
|
-
"release-it": "^17.
|
|
96
|
+
"release-it": "^17.1.1",
|
|
97
97
|
"strip-ansi": "^6.0.1",
|
|
98
|
-
"typescript": "^5.
|
|
98
|
+
"typescript": "^5.4.2"
|
|
99
99
|
},
|
|
100
100
|
"publishConfig": {
|
|
101
101
|
"registry": "https://registry.npmjs.org"
|
package/typings/index.flow.js
CHANGED
|
@@ -74,27 +74,15 @@ type WaitForOptions = {
|
|
|
74
74
|
onTimeout?: (error: Error) => Error,
|
|
75
75
|
};
|
|
76
76
|
|
|
77
|
-
type WaitForFunction = <T = any>(
|
|
78
|
-
expectation: () => T,
|
|
79
|
-
options?: WaitForOptions
|
|
80
|
-
) => Promise<T>;
|
|
77
|
+
type WaitForFunction = <T = any>(expectation: () => T, options?: WaitForOptions) => Promise<T>;
|
|
81
78
|
|
|
82
79
|
type ByTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
83
80
|
|
|
84
81
|
interface ByTextQueries {
|
|
85
82
|
getByText: (text: TextMatch, options?: ByTextOptions) => ReactTestInstance;
|
|
86
|
-
getAllByText: (
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
) => Array<ReactTestInstance>;
|
|
90
|
-
queryByText: (
|
|
91
|
-
name: TextMatch,
|
|
92
|
-
options?: ByTextOptions
|
|
93
|
-
) => ReactTestInstance | null;
|
|
94
|
-
queryAllByText: (
|
|
95
|
-
text: TextMatch,
|
|
96
|
-
options?: ByTextOptions
|
|
97
|
-
) => Array<ReactTestInstance> | [];
|
|
83
|
+
getAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance>;
|
|
84
|
+
queryByText: (name: TextMatch, options?: ByTextOptions) => ReactTestInstance | null;
|
|
85
|
+
queryAllByText: (text: TextMatch, options?: ByTextOptions) => Array<ReactTestInstance> | [];
|
|
98
86
|
findByText: (
|
|
99
87
|
text: TextMatch,
|
|
100
88
|
queryOptions?: ByTextOptions,
|
|
@@ -110,22 +98,10 @@ interface ByTextQueries {
|
|
|
110
98
|
type ByTestIdOptions = CommonQueryOptions & TextMatchOptions;
|
|
111
99
|
|
|
112
100
|
interface ByTestIdQueries {
|
|
113
|
-
getByTestId: (
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
) => ReactTestInstance;
|
|
117
|
-
getAllByTestId: (
|
|
118
|
-
testID: TextMatch,
|
|
119
|
-
options?: ByTestIdOptions
|
|
120
|
-
) => Array<ReactTestInstance>;
|
|
121
|
-
queryByTestId: (
|
|
122
|
-
testID: TextMatch,
|
|
123
|
-
options?: ByTestIdOptions
|
|
124
|
-
) => ReactTestInstance | null;
|
|
125
|
-
queryAllByTestId: (
|
|
126
|
-
testID: TextMatch,
|
|
127
|
-
options?: ByTestIdOptions
|
|
128
|
-
) => Array<ReactTestInstance> | [];
|
|
101
|
+
getByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance;
|
|
102
|
+
getAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance>;
|
|
103
|
+
queryByTestId: (testID: TextMatch, options?: ByTestIdOptions) => ReactTestInstance | null;
|
|
104
|
+
queryAllByTestId: (testID: TextMatch, options?: ByTestIdOptions) => Array<ReactTestInstance> | [];
|
|
129
105
|
findByTestId: (
|
|
130
106
|
testID: TextMatch,
|
|
131
107
|
queryOptions?: ByTestIdOptions,
|
|
@@ -141,10 +117,7 @@ interface ByTestIdQueries {
|
|
|
141
117
|
type ByDisplayValueOptions = CommonQueryOptions & TextMatchOptions;
|
|
142
118
|
|
|
143
119
|
interface ByDisplayValueQueries {
|
|
144
|
-
getByDisplayValue: (
|
|
145
|
-
value: TextMatch,
|
|
146
|
-
options?: ByDisplayValueOptions
|
|
147
|
-
) => ReactTestInstance;
|
|
120
|
+
getByDisplayValue: (value: TextMatch, options?: ByDisplayValueOptions) => ReactTestInstance;
|
|
148
121
|
getAllByDisplayValue: (
|
|
149
122
|
value: TextMatch,
|
|
150
123
|
options?: ByDisplayValueOptions
|
|
@@ -202,24 +175,16 @@ interface ByPlaceholderTextQueries {
|
|
|
202
175
|
|
|
203
176
|
interface UnsafeByTypeQueries {
|
|
204
177
|
UNSAFE_getByType: <P>(type: React.ComponentType<P>) => ReactTestInstance;
|
|
205
|
-
UNSAFE_getAllByType: <P>(
|
|
206
|
-
|
|
207
|
-
) => Array<ReactTestInstance
|
|
208
|
-
UNSAFE_queryByType: <P>(
|
|
209
|
-
type: React.ComponentType<P>
|
|
210
|
-
) => ReactTestInstance | null;
|
|
211
|
-
UNSAFE_queryAllByType: <P>(
|
|
212
|
-
type: React.ComponentType<P>
|
|
213
|
-
) => Array<ReactTestInstance> | [];
|
|
178
|
+
UNSAFE_getAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance>;
|
|
179
|
+
UNSAFE_queryByType: <P>(type: React.ComponentType<P>) => ReactTestInstance | null;
|
|
180
|
+
UNSAFE_queryAllByType: <P>(type: React.ComponentType<P>) => Array<ReactTestInstance> | [];
|
|
214
181
|
}
|
|
215
182
|
|
|
216
183
|
interface UnsafeByPropsQueries {
|
|
217
184
|
UNSAFE_getByProps: (props: { [string]: any }) => ReactTestInstance;
|
|
218
185
|
UNSAFE_getAllByProps: (props: { [string]: any }) => Array<ReactTestInstance>;
|
|
219
186
|
UNSAFE_queryByProps: (props: { [string]: any }) => ReactTestInstance | null;
|
|
220
|
-
UNSAFE_queryAllByProps: (props: { [string]: any }) =>
|
|
221
|
-
| Array<ReactTestInstance>
|
|
222
|
-
| [];
|
|
187
|
+
UNSAFE_queryAllByProps: (props: { [string]: any }) => Array<ReactTestInstance> | [];
|
|
223
188
|
}
|
|
224
189
|
|
|
225
190
|
type ByRoleOptions = CommonQueryOptions & {
|
|
@@ -233,22 +198,10 @@ type ByHintTextOptions = CommonQueryOptions & TextMatchOptions;
|
|
|
233
198
|
|
|
234
199
|
interface A11yAPI {
|
|
235
200
|
// Label
|
|
236
|
-
getByLabelText: (
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
) =>
|
|
240
|
-
getAllByLabelText: (
|
|
241
|
-
matcher: TextMatch,
|
|
242
|
-
options?: ByLabelTextOptions
|
|
243
|
-
) => GetAllReturn;
|
|
244
|
-
queryByLabelText: (
|
|
245
|
-
matcher: TextMatch,
|
|
246
|
-
options?: ByLabelTextOptions
|
|
247
|
-
) => QueryReturn;
|
|
248
|
-
queryAllByLabelText: (
|
|
249
|
-
matcher: TextMatch,
|
|
250
|
-
options?: ByLabelTextOptions
|
|
251
|
-
) => QueryAllReturn;
|
|
201
|
+
getByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetReturn;
|
|
202
|
+
getAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => GetAllReturn;
|
|
203
|
+
queryByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryReturn;
|
|
204
|
+
queryAllByLabelText: (matcher: TextMatch, options?: ByLabelTextOptions) => QueryAllReturn;
|
|
252
205
|
findByLabelText: (
|
|
253
206
|
matcher: TextMatch,
|
|
254
207
|
queryOptions?: ByLabelTextOptions,
|
|
@@ -263,30 +216,12 @@ interface A11yAPI {
|
|
|
263
216
|
// Hint
|
|
264
217
|
getByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
265
218
|
getByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetReturn;
|
|
266
|
-
getAllByA11yHint: (
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
) =>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
options?: ByHintTextOptions
|
|
273
|
-
) => GetAllReturn;
|
|
274
|
-
queryByA11yHint: (
|
|
275
|
-
matcher: TextMatch,
|
|
276
|
-
options?: ByHintTextOptions
|
|
277
|
-
) => QueryReturn;
|
|
278
|
-
queryByHintText: (
|
|
279
|
-
matcher: TextMatch,
|
|
280
|
-
options?: ByHintTextOptions
|
|
281
|
-
) => QueryReturn;
|
|
282
|
-
queryAllByA11yHint: (
|
|
283
|
-
matcher: TextMatch,
|
|
284
|
-
options?: ByHintTextOptions
|
|
285
|
-
) => QueryAllReturn;
|
|
286
|
-
queryAllByHintText: (
|
|
287
|
-
matcher: TextMatch,
|
|
288
|
-
options?: ByHintTextOptions
|
|
289
|
-
) => QueryAllReturn;
|
|
219
|
+
getAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
220
|
+
getAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => GetAllReturn;
|
|
221
|
+
queryByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
222
|
+
queryByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryReturn;
|
|
223
|
+
queryAllByA11yHint: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
224
|
+
queryAllByHintText: (matcher: TextMatch, options?: ByHintTextOptions) => QueryAllReturn;
|
|
290
225
|
findByA11yHint: (
|
|
291
226
|
matcher: TextMatch,
|
|
292
227
|
queryOptions?: ByHintTextOptions,
|
|
@@ -310,18 +245,9 @@ interface A11yAPI {
|
|
|
310
245
|
|
|
311
246
|
// Role
|
|
312
247
|
getByRole: (matcher: A11yRole | RegExp, role?: ByRoleOptions) => GetReturn;
|
|
313
|
-
getAllByRole: (
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
) => GetAllReturn;
|
|
317
|
-
queryByRole: (
|
|
318
|
-
matcher: A11yRole | RegExp,
|
|
319
|
-
options?: ByRoleOptions
|
|
320
|
-
) => QueryReturn;
|
|
321
|
-
queryAllByRole: (
|
|
322
|
-
matcher: A11yRole | RegExp,
|
|
323
|
-
options?: ByRoleOptions
|
|
324
|
-
) => QueryAllReturn;
|
|
248
|
+
getAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => GetAllReturn;
|
|
249
|
+
queryByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryReturn;
|
|
250
|
+
queryAllByRole: (matcher: A11yRole | RegExp, options?: ByRoleOptions) => QueryAllReturn;
|
|
325
251
|
findByRole: (
|
|
326
252
|
matcher: A11yRole | RegExp,
|
|
327
253
|
queryOptions?: ByRoleOptions,
|
|
@@ -334,22 +260,10 @@ interface A11yAPI {
|
|
|
334
260
|
) => FindAllReturn;
|
|
335
261
|
|
|
336
262
|
// State
|
|
337
|
-
getByA11yState: (
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
) =>
|
|
341
|
-
getAllByA11yState: (
|
|
342
|
-
matcher: A11yState,
|
|
343
|
-
options?: CommonQueryOptions
|
|
344
|
-
) => GetAllReturn;
|
|
345
|
-
queryByA11yState: (
|
|
346
|
-
matcher: A11yState,
|
|
347
|
-
options?: CommonQueryOptions
|
|
348
|
-
) => QueryReturn;
|
|
349
|
-
queryAllByA11yState: (
|
|
350
|
-
matcher: A11yState,
|
|
351
|
-
options?: CommonQueryOptions
|
|
352
|
-
) => QueryAllReturn;
|
|
263
|
+
getByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetReturn;
|
|
264
|
+
getAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetAllReturn;
|
|
265
|
+
queryByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryReturn;
|
|
266
|
+
queryAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryAllReturn;
|
|
353
267
|
findByA11yState: (
|
|
354
268
|
matcher: A11yState,
|
|
355
269
|
queryOptions?: CommonQueryOptions,
|
|
@@ -362,22 +276,10 @@ interface A11yAPI {
|
|
|
362
276
|
) => FindAllReturn;
|
|
363
277
|
|
|
364
278
|
// Value
|
|
365
|
-
getByA11yValue: (
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
) =>
|
|
369
|
-
getAllByA11yValue: (
|
|
370
|
-
matcher: A11yValue,
|
|
371
|
-
options?: CommonQueryOptions
|
|
372
|
-
) => GetAllReturn;
|
|
373
|
-
queryByA11yValue: (
|
|
374
|
-
matcher: A11yValue,
|
|
375
|
-
options?: CommonQueryOptions
|
|
376
|
-
) => QueryReturn;
|
|
377
|
-
queryAllByA11yValue: (
|
|
378
|
-
matcher: A11yValue,
|
|
379
|
-
options?: CommonQueryOptions
|
|
380
|
-
) => QueryAllReturn;
|
|
279
|
+
getByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetReturn;
|
|
280
|
+
getAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetAllReturn;
|
|
281
|
+
queryByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryReturn;
|
|
282
|
+
queryAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryAllReturn;
|
|
381
283
|
findByA11yValue: (
|
|
382
284
|
matcher: A11yValue,
|
|
383
285
|
queryOptions?: CommonQueryOptions,
|
|
@@ -478,27 +380,17 @@ declare module '@testing-library/react-native' {
|
|
|
478
380
|
defaultHidden: boolean;
|
|
479
381
|
}
|
|
480
382
|
|
|
481
|
-
declare export var configure: (
|
|
482
|
-
options: $Shape<Config & ConfigAliasOptions>
|
|
483
|
-
) => void;
|
|
383
|
+
declare export var configure: (options: $Shape<Config & ConfigAliasOptions>) => void;
|
|
484
384
|
declare export var resetToDefaults: () => void;
|
|
485
385
|
|
|
486
386
|
declare export var act: (callback: () => void) => Thenable;
|
|
487
387
|
declare export var within: (instance: ReactTestInstance) => Queries;
|
|
488
|
-
declare export var getQueriesForElement: (
|
|
489
|
-
|
|
490
|
-
) =>
|
|
491
|
-
|
|
492
|
-
declare export var
|
|
493
|
-
|
|
494
|
-
) => NormalizerFn;
|
|
495
|
-
|
|
496
|
-
declare export var isHiddenFromAccessibility: (
|
|
497
|
-
element: ReactTestInstance | null
|
|
498
|
-
) => boolean;
|
|
499
|
-
declare export var isInaccessible: (
|
|
500
|
-
element: ReactTestInstance | null
|
|
501
|
-
) => boolean;
|
|
388
|
+
declare export var getQueriesForElement: (element: ReactTestInstance) => Queries;
|
|
389
|
+
|
|
390
|
+
declare export var getDefaultNormalizer: (normalizerConfig?: NormalizerConfig) => NormalizerFn;
|
|
391
|
+
|
|
392
|
+
declare export var isHiddenFromAccessibility: (element: ReactTestInstance | null) => boolean;
|
|
393
|
+
declare export var isInaccessible: (element: ReactTestInstance | null) => boolean;
|
|
502
394
|
|
|
503
395
|
declare type RenderHookResult<Result, Props> = {
|
|
504
396
|
rerender: (props: Props) => void,
|