@testing-library/react-native 14.0.0-alpha.6 → 14.0.0-beta.0

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.
Files changed (39) hide show
  1. package/README.md +17 -6
  2. package/build/config.js +10 -4
  3. package/build/config.js.map +1 -1
  4. package/build/event-handler.d.ts +0 -1
  5. package/build/event-handler.js +0 -1
  6. package/build/event-handler.js.map +1 -1
  7. package/build/fire-event.d.ts +0 -2
  8. package/build/fire-event.js +0 -5
  9. package/build/fire-event.js.map +1 -1
  10. package/build/helpers/errors.d.ts +1 -3
  11. package/build/helpers/errors.js +3 -36
  12. package/build/helpers/errors.js.map +1 -1
  13. package/build/helpers/validate-options.d.ts +9 -0
  14. package/build/helpers/validate-options.js +32 -0
  15. package/build/helpers/validate-options.js.map +1 -0
  16. package/build/render-hook.js +7 -1
  17. package/build/render-hook.js.map +1 -1
  18. package/build/render.d.ts +1 -1
  19. package/build/render.js +6 -4
  20. package/build/render.js.map +1 -1
  21. package/build/test-utils/timers.d.ts +2 -0
  22. package/build/test-utils/timers.js +20 -0
  23. package/build/test-utils/timers.js.map +1 -0
  24. package/build/tsconfig.release.tsbuildinfo +1 -1
  25. package/build/user-event/event-builder/base.d.ts +5 -1
  26. package/build/user-event/event-builder/base.js +1 -1
  27. package/build/user-event/event-builder/base.js.map +1 -1
  28. package/build/user-event/event-builder/common.d.ts +5 -0
  29. package/build/user-event/event-builder/index.d.ts +12 -0
  30. package/build/user-event/event-builder/scroll-view.d.ts +1 -0
  31. package/build/user-event/event-builder/text-input.d.ts +6 -0
  32. package/build/user-event/setup/setup.js +17 -3
  33. package/build/user-event/setup/setup.js.map +1 -1
  34. package/build/wait-for.js +8 -13
  35. package/build/wait-for.js.map +1 -1
  36. package/package.json +4 -4
  37. package/build/react-versions.d.ts +0 -1
  38. package/build/react-versions.js +0 -14
  39. package/build/react-versions.js.map +0 -1
package/README.md CHANGED
@@ -12,6 +12,8 @@
12
12
  [![MIT License][license-badge]][license]
13
13
  [![Sponsored by Callstack][callstack-badge]][callstack]
14
14
 
15
+ > ⚠️ **Beta Version:** This version is currently in beta. APIs and behavior may change before the stable release. Please report any issues you encounter.
16
+
15
17
  ## The problem
16
18
 
17
19
  You want to write maintainable tests for your React Native components. As a part of this goal, you want your tests to avoid including implementation details of your components and rather focus on making your tests give you the confidence for which they are intended. As part of this, you want your tests to be maintainable in the long run so refactors of your components (changes to implementation but not functionality) don't break your tests and slow you and your team down.
@@ -30,13 +32,21 @@ Open a Terminal in your project's folder and run:
30
32
 
31
33
  ```sh
32
34
  # Yarn install:
33
- yarn add --dev @testing-library/react-native
35
+ yarn add --dev @testing-library/react-native@alpha
34
36
 
35
37
  # NPM install
36
- npm install --save-dev @testing-library/react-native
38
+ npm install --save-dev @testing-library/react-native@alpha
37
39
  ```
38
40
 
39
- This library has a `peerDependencies` listing for `test-renderer`. Make sure that your `test-renderer` version matches exactly the `react` version, avoid using `^` in version number.
41
+ This library has a `peerDependencies` listing for [Test Renderer](https://github.com/mdjastrzebski/test-renderer). Make sure to install it as a dev dependency:
42
+
43
+ ```sh
44
+ # Yarn install:
45
+ yarn add --dev test-renderer
46
+
47
+ # NPM install
48
+ npm install --save-dev test-renderer
49
+ ```
40
50
 
41
51
  ### Additional Jest matchers
42
52
 
@@ -57,7 +67,7 @@ test('form submits two answers', async () => {
57
67
  const onSubmit = jest.fn();
58
68
 
59
69
  const user = userEvent.setup();
60
- render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />);
70
+ await render(<QuestionsBoard questions={questions} onSubmit={onSubmit} />);
61
71
 
62
72
  const answerInputs = screen.getAllByLabelText('answer input');
63
73
 
@@ -85,9 +95,9 @@ React Native Testing Library consists of following APIs:
85
95
  - [`screen` object](https://callstack.github.io/react-native-testing-library/docs/api/screen) - access rendered UI:
86
96
  - [Queries](https://callstack.github.io/react-native-testing-library/docs/api/queries) - find rendered components by various predicates: role, text, test ids, etc
87
97
  - Lifecycle methods: [`rerender`](https://callstack.github.io/react-native-testing-library/docs/api/screen#rerender), [`unmount`](https://callstack.github.io/react-native-testing-library/docs/api/screen#unmount)
88
- - Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/api/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/api/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/api/screen#root)
98
+ - Helpers: [`debug`](https://callstack.github.io/react-native-testing-library/docs/api/screen#debug), [`toJSON`](https://callstack.github.io/react-native-testing-library/docs/api/screen#tojson), [`root`](https://callstack.github.io/react-native-testing-library/docs/api/screen#root), [`container`](https://callstack.github.io/react-native-testing-library/docs/api/screen#container)
89
99
  - [Jest matchers](https://callstack.github.io/react-native-testing-library/docs/api/jest-matchers) - validate assumptions about your UI
90
- - [User Event](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/user-event#type) in a realistic way
100
+ - [User Event](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event) - simulate common user interactions like [`press`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#press) or [`type`](https://callstack.github.io/react-native-testing-library/docs/api/events/user-event#type) in a realistic way
91
101
  - [Fire Event](https://callstack.github.io/react-native-testing-library/docs/api/events/fire-event) - simulate any component event in a simplified way
92
102
  - [`renderHook` function](https://callstack.github.io/react-native-testing-library/docs/api/misc/render-hook) - render hooks for testing purposes
93
103
  - Miscellaneous APIs:
@@ -98,6 +108,7 @@ React Native Testing Library consists of following APIs:
98
108
 
99
109
  ## Migration Guides
100
110
 
111
+ - **[Migration to 14.0](https://callstack.github.io/react-native-testing-library/docs/migration/v14)** - Drops React 18, async APIs by default
101
112
  - [Migration to 13.0](https://callstack.github.io/react-native-testing-library/docs/migration/v13)
102
113
  - [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
103
114
 
package/build/config.js CHANGED
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.configure = configure;
7
7
  exports.getConfig = getConfig;
8
8
  exports.resetToDefaults = resetToDefaults;
9
+ var _validateOptions = require("./helpers/validate-options");
9
10
  /**
10
11
  * Global configuration options for React Native Testing Library.
11
12
  */
@@ -23,14 +24,19 @@ let config = {
23
24
  */
24
25
  function configure(options) {
25
26
  const {
27
+ asyncUtilTimeout,
28
+ defaultDebugOptions,
26
29
  defaultHidden,
27
- ...restOptions
30
+ defaultIncludeHiddenElements,
31
+ ...rest
28
32
  } = options;
29
- const defaultIncludeHiddenElements = restOptions.defaultIncludeHiddenElements ?? defaultHidden ?? config.defaultIncludeHiddenElements;
33
+ (0, _validateOptions.validateOptions)('configure', rest, configure);
34
+ const resolvedDefaultIncludeHiddenElements = defaultIncludeHiddenElements ?? defaultHidden ?? config.defaultIncludeHiddenElements;
30
35
  config = {
31
36
  ...config,
32
- ...restOptions,
33
- defaultIncludeHiddenElements
37
+ asyncUtilTimeout: asyncUtilTimeout ?? config.asyncUtilTimeout,
38
+ defaultDebugOptions,
39
+ defaultIncludeHiddenElements: resolvedDefaultIncludeHiddenElements
34
40
  };
35
41
  }
36
42
  function resetToDefaults() {
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import type { DebugOptions } from './helpers/debug';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nconst defaultConfig: Config = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const { defaultHidden, ...restOptions } = options;\n\n const defaultIncludeHiddenElements =\n restOptions.defaultIncludeHiddenElements ??\n defaultHidden ??\n config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n ...restOptions,\n defaultIncludeHiddenElements,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;AAEA;AACA;AACA;;AAkBA,MAAMA,aAAqB,GAAG;EAC5BC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMH,4BAA4B,GAChCK,WAAW,CAACL,4BAA4B,IACxCI,aAAa,IACbH,MAAM,CAACD,4BAA4B;EAErCC,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdL;EACF,CAAC;AACH;AAEO,SAASM,eAAeA,CAAA,EAAG;EAChCL,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASS,SAASA,CAAA,EAAG;EAC1B,OAAON,MAAM;AACf","ignoreList":[]}
1
+ {"version":3,"file":"config.js","names":["_validateOptions","require","defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultDebugOptions","defaultHidden","rest","validateOptions","resolvedDefaultIncludeHiddenElements","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import type { DebugOptions } from './helpers/debug';\nimport { validateOptions } from './helpers/validate-options';\n\n/**\n * Global configuration options for React Native Testing Library.\n */\n\nexport type Config = {\n /** Default timeout, in ms, for `waitFor` and `findBy*` queries. */\n asyncUtilTimeout: number;\n\n /** Default value for `includeHiddenElements` query option. */\n defaultIncludeHiddenElements: boolean;\n\n /** Default options for `debug` helper. */\n defaultDebugOptions?: Partial<DebugOptions>;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nconst defaultConfig: Config = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n};\n\nlet config = { ...defaultConfig };\n\n/**\n * Configure global options for React Native Testing Library.\n */\nexport function configure(options: Partial<Config & ConfigAliasOptions>) {\n const {\n asyncUtilTimeout,\n defaultDebugOptions,\n defaultHidden,\n defaultIncludeHiddenElements,\n ...rest\n } = options;\n\n validateOptions('configure', rest, configure);\n\n const resolvedDefaultIncludeHiddenElements =\n defaultIncludeHiddenElements ?? defaultHidden ?? config.defaultIncludeHiddenElements;\n\n config = {\n ...config,\n asyncUtilTimeout: asyncUtilTimeout ?? config.asyncUtilTimeout,\n defaultDebugOptions,\n defaultIncludeHiddenElements: resolvedDefaultIncludeHiddenElements,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;AACA,IAAAA,gBAAA,GAAAC,OAAA;AAEA;AACA;AACA;;AAkBA,MAAMC,aAAqB,GAAG;EAC5BC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE;AAChC,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGH;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASI,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IACJJ,gBAAgB;IAChBK,mBAAmB;IACnBC,aAAa;IACbL,4BAA4B;IAC5B,GAAGM;EACL,CAAC,GAAGH,OAAO;EAEX,IAAAI,gCAAe,EAAC,WAAW,EAAED,IAAI,EAAEJ,SAAS,CAAC;EAE7C,MAAMM,oCAAoC,GACxCR,4BAA4B,IAAIK,aAAa,IAAIJ,MAAM,CAACD,4BAA4B;EAEtFC,MAAM,GAAG;IACP,GAAGA,MAAM;IACTF,gBAAgB,EAAEA,gBAAgB,IAAIE,MAAM,CAACF,gBAAgB;IAC7DK,mBAAmB;IACnBJ,4BAA4B,EAAEQ;EAChC,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCR,MAAM,GAAG;IAAE,GAAGH;EAAc,CAAC;AAC/B;AAEO,SAASY,SAASA,CAAA,EAAG;EAC1B,OAAOT,MAAM;AACf","ignoreList":[]}
@@ -4,4 +4,3 @@ export type EventHandlerOptions = {
4
4
  loose?: boolean;
5
5
  };
6
6
  export declare function getEventHandlerFromProps(props: Record<string, unknown>, eventName: string, options?: EventHandlerOptions): EventHandler | undefined;
7
- export declare function getEventHandlerName(eventName: string): string;
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getEventHandlerFromProps = getEventHandlerFromProps;
7
- exports.getEventHandlerName = getEventHandlerName;
8
7
  function getEventHandlerFromProps(props, eventName, options) {
9
8
  const handlerName = getEventHandlerName(eventName);
10
9
  if (typeof props[handlerName] === 'function') {
@@ -1 +1 @@
1
- {"version":3,"file":"event-handler.js","names":["getEventHandlerFromProps","props","eventName","options","handlerName","getEventHandlerName","loose","undefined","capitalizeFirstLetter","str","charAt","toUpperCase","slice"],"sources":["../src/event-handler.ts"],"sourcesContent":["export type EventHandler = (...args: unknown[]) => unknown;\n\nexport type EventHandlerOptions = {\n /** Include check for event handler named without adding `on*` prefix. */\n loose?: boolean;\n};\n\nexport function getEventHandlerFromProps(\n props: Record<string, unknown>,\n eventName: string,\n options?: EventHandlerOptions,\n): EventHandler | undefined {\n const handlerName = getEventHandlerName(eventName);\n if (typeof props[handlerName] === 'function') {\n return props[handlerName] as EventHandler;\n }\n\n if (options?.loose && typeof props[eventName] === 'function') {\n return props[eventName] as EventHandler;\n }\n\n if (typeof props[`testOnly_${handlerName}`] === 'function') {\n return props[`testOnly_${handlerName}`] as EventHandler;\n }\n\n if (options?.loose && typeof props[`testOnly_${eventName}`] === 'function') {\n return props[`testOnly_${eventName}`] as EventHandler;\n }\n\n return undefined;\n}\n\nexport function getEventHandlerName(eventName: string) {\n return `on${capitalizeFirstLetter(eventName)}`;\n}\n\nfunction capitalizeFirstLetter(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;;AAOO,SAASA,wBAAwBA,CACtCC,KAA8B,EAC9BC,SAAiB,EACjBC,OAA6B,EACH;EAC1B,MAAMC,WAAW,GAAGC,mBAAmB,CAACH,SAAS,CAAC;EAClD,IAAI,OAAOD,KAAK,CAACG,WAAW,CAAC,KAAK,UAAU,EAAE;IAC5C,OAAOH,KAAK,CAACG,WAAW,CAAC;EAC3B;EAEA,IAAID,OAAO,EAAEG,KAAK,IAAI,OAAOL,KAAK,CAACC,SAAS,CAAC,KAAK,UAAU,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS,CAAC;EACzB;EAEA,IAAI,OAAOD,KAAK,CAAC,YAAYG,WAAW,EAAE,CAAC,KAAK,UAAU,EAAE;IAC1D,OAAOH,KAAK,CAAC,YAAYG,WAAW,EAAE,CAAC;EACzC;EAEA,IAAID,OAAO,EAAEG,KAAK,IAAI,OAAOL,KAAK,CAAC,YAAYC,SAAS,EAAE,CAAC,KAAK,UAAU,EAAE;IAC1E,OAAOD,KAAK,CAAC,YAAYC,SAAS,EAAE,CAAC;EACvC;EAEA,OAAOK,SAAS;AAClB;AAEO,SAASF,mBAAmBA,CAACH,SAAiB,EAAE;EACrD,OAAO,KAAKM,qBAAqB,CAACN,SAAS,CAAC,EAAE;AAChD;AAEA,SAASM,qBAAqBA,CAACC,GAAW,EAAE;EAC1C,OAAOA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,CAAC,CAAC;AACnD","ignoreList":[]}
1
+ {"version":3,"file":"event-handler.js","names":["getEventHandlerFromProps","props","eventName","options","handlerName","getEventHandlerName","loose","undefined","capitalizeFirstLetter","str","charAt","toUpperCase","slice"],"sources":["../src/event-handler.ts"],"sourcesContent":["export type EventHandler = (...args: unknown[]) => unknown;\n\nexport type EventHandlerOptions = {\n /** Include check for event handler named without adding `on*` prefix. */\n loose?: boolean;\n};\n\nexport function getEventHandlerFromProps(\n props: Record<string, unknown>,\n eventName: string,\n options?: EventHandlerOptions,\n): EventHandler | undefined {\n const handlerName = getEventHandlerName(eventName);\n if (typeof props[handlerName] === 'function') {\n return props[handlerName] as EventHandler;\n }\n\n if (options?.loose && typeof props[eventName] === 'function') {\n return props[eventName] as EventHandler;\n }\n\n if (typeof props[`testOnly_${handlerName}`] === 'function') {\n return props[`testOnly_${handlerName}`] as EventHandler;\n }\n\n if (options?.loose && typeof props[`testOnly_${eventName}`] === 'function') {\n return props[`testOnly_${eventName}`] as EventHandler;\n }\n\n return undefined;\n}\n\nfunction getEventHandlerName(eventName: string) {\n return `on${capitalizeFirstLetter(eventName)}`;\n}\n\nfunction capitalizeFirstLetter(str: string) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n"],"mappings":";;;;;;AAOO,SAASA,wBAAwBA,CACtCC,KAA8B,EAC9BC,SAAiB,EACjBC,OAA6B,EACH;EAC1B,MAAMC,WAAW,GAAGC,mBAAmB,CAACH,SAAS,CAAC;EAClD,IAAI,OAAOD,KAAK,CAACG,WAAW,CAAC,KAAK,UAAU,EAAE;IAC5C,OAAOH,KAAK,CAACG,WAAW,CAAC;EAC3B;EAEA,IAAID,OAAO,EAAEG,KAAK,IAAI,OAAOL,KAAK,CAACC,SAAS,CAAC,KAAK,UAAU,EAAE;IAC5D,OAAOD,KAAK,CAACC,SAAS,CAAC;EACzB;EAEA,IAAI,OAAOD,KAAK,CAAC,YAAYG,WAAW,EAAE,CAAC,KAAK,UAAU,EAAE;IAC1D,OAAOH,KAAK,CAAC,YAAYG,WAAW,EAAE,CAAC;EACzC;EAEA,IAAID,OAAO,EAAEG,KAAK,IAAI,OAAOL,KAAK,CAAC,YAAYC,SAAS,EAAE,CAAC,KAAK,UAAU,EAAE;IAC1E,OAAOD,KAAK,CAAC,YAAYC,SAAS,EAAE,CAAC;EACvC;EAEA,OAAOK,SAAS;AAClB;AAEA,SAASF,mBAAmBA,CAACH,SAAiB,EAAE;EAC9C,OAAO,KAAKM,qBAAqB,CAACN,SAAS,CAAC,EAAE;AAChD;AAEA,SAASM,qBAAqBA,CAACC,GAAW,EAAE;EAC1C,OAAOA,GAAG,CAACC,MAAM,CAAC,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,GAAGF,GAAG,CAACG,KAAK,CAAC,CAAC,CAAC;AACnD","ignoreList":[]}
@@ -1,8 +1,6 @@
1
1
  import type { PressableProps, ScrollViewProps, TextInputProps, TextProps, ViewProps } from 'react-native';
2
2
  import type { HostElement } from 'test-renderer';
3
3
  import type { StringWithAutocomplete } from './types';
4
- export declare function isTouchResponder(element: HostElement): boolean;
5
- export declare function isEventEnabled(element: HostElement, eventName: string, nearestTouchResponder?: HostElement): boolean;
6
4
  type EventNameExtractor<T> = keyof {
7
5
  [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];
8
6
  };
@@ -4,8 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.fireEvent = fireEvent;
7
- exports.isEventEnabled = isEventEnabled;
8
- exports.isTouchResponder = isTouchResponder;
9
7
  var _act = require("./act");
10
8
  var _eventHandler = require("./event-handler");
11
9
  var _componentTree = require("./helpers/component-tree");
@@ -14,9 +12,6 @@ var _pointerEvents = require("./helpers/pointer-events");
14
12
  var _textInput = require("./helpers/text-input");
15
13
  var _nativeState = require("./native-state");
16
14
  function isTouchResponder(element) {
17
- if (!(0, _componentTree.isHostElement)(element)) {
18
- return false;
19
- }
20
15
  return Boolean(element.props.onStartShouldSetResponder) || (0, _hostComponentNames.isHostTextInput)(element);
21
16
  }
22
17
 
@@ -1 +1 @@
1
- {"version":3,"file":"fire-event.js","names":["_act","require","_eventHandler","_componentTree","_hostComponentNames","_pointerEvents","_textInput","_nativeState","isTouchResponder","element","isHostElement","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isEditableTextInput","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandlerFromProps","loose","findEventHandlerFromFiber","unstable_fiber","parent","fiber","memoizedProps","return","type","fireEvent","data","isElementMounted","setNativeStateIfNeeded","returnValue","act","press","changeText","scroll","scrollEventNames","value","nativeState","valueForElement","set","isHostScrollView","contentOffset","tryGetContentOffset","contentOffsetForElement","event","nativeEvent","x","y","Number","isFinite"],"sources":["../src/fire-event.ts"],"sourcesContent":["import type {\n PressableProps,\n ScrollViewProps,\n TextInputProps,\n TextProps,\n ViewProps,\n} from 'react-native';\nimport type { Fiber, HostElement } from 'test-renderer';\n\nimport { act } from './act';\nimport type { EventHandler } from './event-handler';\nimport { getEventHandlerFromProps } from './event-handler';\nimport { isElementMounted, isHostElement } from './helpers/component-tree';\nimport { isHostScrollView, isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isEditableTextInput } from './helpers/text-input';\nimport { nativeState } from './native-state';\nimport type { Point, StringWithAutocomplete } from './types';\n\nexport function isTouchResponder(element: HostElement) {\n if (!isHostElement(element)) {\n return false;\n }\n\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nexport function isEventEnabled(\n element: HostElement,\n eventName: string,\n nearestTouchResponder?: HostElement,\n) {\n if (nearestTouchResponder != null && isHostTextInput(nearestTouchResponder)) {\n return (\n isEditableTextInput(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: HostElement,\n eventName: string,\n nearestTouchResponder?: HostElement,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler =\n getEventHandlerFromProps(element.props, eventName, { loose: true }) ??\n findEventHandlerFromFiber(element.unstable_fiber, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) {\n return handler;\n }\n\n if (element.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction findEventHandlerFromFiber(fiber: Fiber | null, eventName: string): EventHandler | null {\n // Container fibers have memoizedProps set to null\n if (!fiber?.memoizedProps) {\n return null;\n }\n\n const handler = getEventHandlerFromProps(fiber.memoizedProps, eventName, { loose: true });\n if (handler) {\n return handler;\n }\n\n // No parent fiber or we reached another host element\n if (fiber.return === null || typeof fiber.return.type === 'string') {\n return null;\n }\n\n return findEventHandlerFromFiber(fiber.return, eventName);\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nasync function fireEvent(element: HostElement, eventName: EventName, ...data: unknown[]) {\n if (!isElementMounted(element)) {\n return;\n }\n\n setNativeStateIfNeeded(element, eventName, data[0]);\n\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n await act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'scroll', ...data);\n\nexport { fireEvent };\n\nconst scrollEventNames = new Set([\n 'scroll',\n 'scrollBeginDrag',\n 'scrollEndDrag',\n 'momentumScrollBegin',\n 'momentumScrollEnd',\n]);\n\nfunction setNativeStateIfNeeded(element: HostElement, eventName: string, value: unknown) {\n if (eventName === 'changeText' && typeof value === 'string' && isEditableTextInput(element)) {\n nativeState.valueForElement.set(element, value);\n }\n\n if (scrollEventNames.has(eventName) && isHostScrollView(element)) {\n const contentOffset = tryGetContentOffset(value);\n if (contentOffset) {\n nativeState.contentOffsetForElement.set(element, contentOffset);\n }\n }\n}\n\nfunction tryGetContentOffset(event: unknown): Point | null {\n try {\n // @ts-expect-error: try to extract contentOffset from the event value\n const contentOffset = event?.nativeEvent?.contentOffset;\n const x = contentOffset?.x;\n const y = contentOffset?.y;\n if (typeof x === 'number' || typeof y === 'number') {\n return {\n x: Number.isFinite(x) ? x : 0,\n y: Number.isFinite(y) ? y : 0,\n };\n }\n } catch {\n // Do nothing\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;AASA,IAAAA,IA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IAAA7B,8BAAmB,EAACZ,OAAO,CAAC,EAAE;IAC3F0C,wBAAW,CAACC,eAAe,CAACC,GAAG,CAAC5C,OAAO,EAAEyC,KAAK,CAAC;EACjD;EAEA,IAAID,gBAAgB,CAAC3B,GAAG,CAACH,SAAS,CAAC,IAAI,IAAAmC,oCAAgB,EAAC7C,OAAO,CAAC,EAAE;IAChE,MAAM8C,aAAa,GAAGC,mBAAmB,CAACN,KAAK,CAAC;IAChD,IAAIK,aAAa,EAAE;MACjBJ,wBAAW,CAACM,uBAAuB,CAACJ,GAAG,CAAC5C,OAAO,EAAE8C,aAAa,CAAC;IACjE;EACF;AACF;AAEA,SAASC,mBAAmBA,CAACE,KAAc,EAAgB;EACzD,IAAI;IACF;IACA,MAAMH,aAAa,GAAGG,KAAK,EAAEC,WAAW,EAAEJ,aAAa;IACvD,MAAMK,CAAC,GAAGL,aAAa,EAAEK,CAAC;IAC1B,MAAMC,CAAC,GAAGN,aAAa,EAAEM,CAAC;IAC1B,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;MAClD,OAAO;QACLD,CAAC,EAAEE,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,GAAGA,CAAC,GAAG,CAAC;QAC7BC,CAAC,EAAEC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,GAAGA,CAAC,GAAG;MAC9B,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb","ignoreList":[]}
1
+ {"version":3,"file":"fire-event.js","names":["_act","require","_eventHandler","_componentTree","_hostComponentNames","_pointerEvents","_textInput","_nativeState","isTouchResponder","element","Boolean","props","onStartShouldSetResponder","isHostTextInput","eventsAffectedByPointerEventsProp","Set","textInputEventsIgnoringEditableProp","isEventEnabled","eventName","nearestTouchResponder","isEditableTextInput","has","isPointerEventEnabled","touchStart","touchMove","onMoveShouldSetResponder","undefined","findEventHandler","touchResponder","handler","getEventHandlerFromProps","loose","findEventHandlerFromFiber","unstable_fiber","parent","fiber","memoizedProps","return","type","fireEvent","data","isElementMounted","setNativeStateIfNeeded","returnValue","act","press","changeText","scroll","scrollEventNames","value","nativeState","valueForElement","set","isHostScrollView","contentOffset","tryGetContentOffset","contentOffsetForElement","event","nativeEvent","x","y","Number","isFinite"],"sources":["../src/fire-event.ts"],"sourcesContent":["import type {\n PressableProps,\n ScrollViewProps,\n TextInputProps,\n TextProps,\n ViewProps,\n} from 'react-native';\nimport type { Fiber, HostElement } from 'test-renderer';\n\nimport { act } from './act';\nimport type { EventHandler } from './event-handler';\nimport { getEventHandlerFromProps } from './event-handler';\nimport { isElementMounted } from './helpers/component-tree';\nimport { isHostScrollView, isHostTextInput } from './helpers/host-component-names';\nimport { isPointerEventEnabled } from './helpers/pointer-events';\nimport { isEditableTextInput } from './helpers/text-input';\nimport { nativeState } from './native-state';\nimport type { Point, StringWithAutocomplete } from './types';\n\nfunction isTouchResponder(element: HostElement) {\n return Boolean(element.props.onStartShouldSetResponder) || isHostTextInput(element);\n}\n\n/**\n * List of events affected by `pointerEvents` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst eventsAffectedByPointerEventsProp = new Set(['press', 'onPress']);\n\n/**\n * List of `TextInput` events not affected by `editable` prop.\n *\n * Note: `fireEvent` is accepting both `press` and `onPress` for event names,\n * so we need cover both forms.\n */\nconst textInputEventsIgnoringEditableProp = new Set([\n 'contentSizeChange',\n 'onContentSizeChange',\n 'layout',\n 'onLayout',\n 'scroll',\n 'onScroll',\n]);\n\nfunction isEventEnabled(\n element: HostElement,\n eventName: string,\n nearestTouchResponder?: HostElement,\n) {\n if (nearestTouchResponder != null && isHostTextInput(nearestTouchResponder)) {\n return (\n isEditableTextInput(nearestTouchResponder) ||\n textInputEventsIgnoringEditableProp.has(eventName)\n );\n }\n\n if (eventsAffectedByPointerEventsProp.has(eventName) && !isPointerEventEnabled(element)) {\n return false;\n }\n\n const touchStart = nearestTouchResponder?.props.onStartShouldSetResponder?.();\n const touchMove = nearestTouchResponder?.props.onMoveShouldSetResponder?.();\n if (touchStart || touchMove) {\n return true;\n }\n\n return touchStart === undefined && touchMove === undefined;\n}\n\nfunction findEventHandler(\n element: HostElement,\n eventName: string,\n nearestTouchResponder?: HostElement,\n): EventHandler | null {\n const touchResponder = isTouchResponder(element) ? element : nearestTouchResponder;\n\n const handler =\n getEventHandlerFromProps(element.props, eventName, { loose: true }) ??\n findEventHandlerFromFiber(element.unstable_fiber, eventName);\n if (handler && isEventEnabled(element, eventName, touchResponder)) {\n return handler;\n }\n\n if (element.parent === null) {\n return null;\n }\n\n return findEventHandler(element.parent, eventName, touchResponder);\n}\n\nfunction findEventHandlerFromFiber(fiber: Fiber | null, eventName: string): EventHandler | null {\n // Container fibers have memoizedProps set to null\n if (!fiber?.memoizedProps) {\n return null;\n }\n\n const handler = getEventHandlerFromProps(fiber.memoizedProps, eventName, { loose: true });\n if (handler) {\n return handler;\n }\n\n // No parent fiber or we reached another host element\n if (fiber.return === null || typeof fiber.return.type === 'string') {\n return null;\n }\n\n return findEventHandlerFromFiber(fiber.return, eventName);\n}\n\n// String union type of keys of T that start with on, stripped of 'on'\ntype EventNameExtractor<T> = keyof {\n [K in keyof T as K extends `on${infer Rest}` ? Uncapitalize<Rest> : never]: T[K];\n};\n\ntype EventName = StringWithAutocomplete<\n | EventNameExtractor<ViewProps>\n | EventNameExtractor<TextProps>\n | EventNameExtractor<TextInputProps>\n | EventNameExtractor<PressableProps>\n | EventNameExtractor<ScrollViewProps>\n>;\n\nasync function fireEvent(element: HostElement, eventName: EventName, ...data: unknown[]) {\n if (!isElementMounted(element)) {\n return;\n }\n\n setNativeStateIfNeeded(element, eventName, data[0]);\n\n const handler = findEventHandler(element, eventName);\n if (!handler) {\n return;\n }\n\n let returnValue;\n await act(() => {\n returnValue = handler(...data);\n });\n\n return returnValue;\n}\n\nfireEvent.press = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'press', ...data);\n\nfireEvent.changeText = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'changeText', ...data);\n\nfireEvent.scroll = async (element: HostElement, ...data: unknown[]) =>\n await fireEvent(element, 'scroll', ...data);\n\nexport { fireEvent };\n\nconst scrollEventNames = new Set([\n 'scroll',\n 'scrollBeginDrag',\n 'scrollEndDrag',\n 'momentumScrollBegin',\n 'momentumScrollEnd',\n]);\n\nfunction setNativeStateIfNeeded(element: HostElement, eventName: string, value: unknown) {\n if (eventName === 'changeText' && typeof value === 'string' && isEditableTextInput(element)) {\n nativeState.valueForElement.set(element, value);\n }\n\n if (scrollEventNames.has(eventName) && isHostScrollView(element)) {\n const contentOffset = tryGetContentOffset(value);\n if (contentOffset) {\n nativeState.contentOffsetForElement.set(element, contentOffset);\n }\n }\n}\n\nfunction tryGetContentOffset(event: unknown): Point | null {\n try {\n // @ts-expect-error: try to extract contentOffset from the event value\n const contentOffset = event?.nativeEvent?.contentOffset;\n const x = contentOffset?.x;\n const y = contentOffset?.y;\n\n if (typeof x === 'number' || typeof y === 'number') {\n return {\n x: Number.isFinite(x) ? x : 0,\n y: Number.isFinite(y) ? y : 0,\n };\n }\n } catch {\n // Do nothing\n }\n\n return null;\n}\n"],"mappings":";;;;;;AASA,IAAAA,IAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,mBAAA,GAAAH,OAAA;AACA,IAAAI,cAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAGA,SAASO,gBAAgBA,CAACC,OAAoB,EAAE;EAC9C,OAAOC,OAAO,CAACD,OAAO,CAACE,KAAK,CAACC,yBAAyB,CAAC,IAAI,IAAAC,mCAAe,EAACJ,OAAO,CAAC;AACrF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMK,iCAAiC,GAAG,IAAIC,GA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IACvD,MAAMK,CAAC,GAAGL,aAAa,EAAEK,CAAC;IAC1B,MAAMC,CAAC,GAAGN,aAAa,EAAEM,CAAC;IAE1B,IAAI,OAAOD,CAAC,KAAK,QAAQ,IAAI,OAAOC,CAAC,KAAK,QAAQ,EAAE;MAClD,OAAO;QACLD,CAAC,EAAEE,MAAM,CAACC,QAAQ,CAACH,CAAC,CAAC,GAAGA,CAAC,GAAG,CAAC;QAC7BC,CAAC,EAAEC,MAAM,CAACC,QAAQ,CAACF,CAAC,CAAC,GAAGA,CAAC,GAAG;MAC9B,CAAC;IACH;EACF,CAAC,CAAC,MAAM;IACN;EAAA;EAGF,OAAO,IAAI;AACb","ignoreList":[]}
@@ -1,6 +1,4 @@
1
1
  export declare class ErrorWithStack extends Error {
2
2
  constructor(message: string | undefined, callsite: Function);
3
3
  }
4
- export declare const prepareErrorMessage: (error: unknown, name?: string, value?: unknown) => string;
5
- export declare const createQueryByError: (error: unknown, callsite: Function) => null;
6
- export declare function copyStackTrace(target: unknown, stackTraceSource: Error): void;
4
+ export declare function copyStackTraceIfNeeded(target: unknown, stackTraceSource: Error | undefined): void;
@@ -4,10 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.ErrorWithStack = void 0;
7
- exports.copyStackTrace = copyStackTrace;
8
- exports.prepareErrorMessage = exports.createQueryByError = void 0;
9
- var _prettyFormat = _interopRequireDefault(require("pretty-format"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
7
+ exports.copyStackTraceIfNeeded = copyStackTraceIfNeeded;
11
8
  class ErrorWithStack extends Error {
12
9
  // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
13
10
  constructor(message, callsite) {
@@ -18,38 +15,8 @@ class ErrorWithStack extends Error {
18
15
  }
19
16
  }
20
17
  exports.ErrorWithStack = ErrorWithStack;
21
- const prepareErrorMessage = (error, name, value) => {
22
- let errorMessage;
23
- if (error instanceof Error) {
24
- // Strip info about custom predicate
25
- errorMessage = error.message.replace(/ matching custom predicate[^]*/gm, '');
26
- } else if (error && typeof error === 'object') {
27
- errorMessage = error.toString();
28
- } else {
29
- errorMessage = 'Caught unknown error';
30
- }
31
- if (name && value) {
32
- errorMessage += ` with ${name} ${(0, _prettyFormat.default)(value, {
33
- min: true
34
- })}`;
35
- }
36
- return errorMessage;
37
- };
38
-
39
- // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
40
- exports.prepareErrorMessage = prepareErrorMessage;
41
- const createQueryByError = (error, callsite) => {
42
- if (error instanceof Error) {
43
- if (error.message.includes('No instances found')) {
44
- return null;
45
- }
46
- throw new ErrorWithStack(error.message, callsite);
47
- }
48
- throw new ErrorWithStack(`Query: caught unknown error type: ${typeof error}, value: ${error}`, callsite);
49
- };
50
- exports.createQueryByError = createQueryByError;
51
- function copyStackTrace(target, stackTraceSource) {
52
- if (target instanceof Error && stackTraceSource.stack) {
18
+ function copyStackTraceIfNeeded(target, stackTraceSource) {
19
+ if (stackTraceSource != null && target instanceof Error && stackTraceSource.stack) {
53
20
  target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);
54
21
  }
55
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","names":["_prettyFormat","_interopRequireDefault","require","e","__esModule","default","ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","prepareErrorMessage","error","name","value","errorMessage","replace","toString","prettyFormat","min","createQueryByError","includes","copyStackTrace","target","stackTraceSource","stack"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["import prettyFormat from 'pretty-format';\n\nexport class ErrorWithStack extends Error {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport const prepareErrorMessage = (\n // TS states that error caught in a catch close are of type `unknown`\n // most real cases will be `Error`, but better safe than sorry\n error: unknown,\n name?: string,\n value?: unknown,\n): string => {\n let errorMessage: string;\n if (error instanceof Error) {\n // Strip info about custom predicate\n errorMessage = error.message.replace(/ matching custom predicate[^]*/gm, '');\n } else if (error && typeof error === 'object') {\n errorMessage = error.toString();\n } else {\n errorMessage = 'Caught unknown error';\n }\n\n if (name && value) {\n errorMessage += ` with ${name} ${prettyFormat(value, { min: true })}`;\n }\n return errorMessage;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\nexport const createQueryByError = (error: unknown, callsite: Function): null => {\n if (error instanceof Error) {\n if (error.message.includes('No instances found')) {\n return null;\n }\n throw new ErrorWithStack(error.message, callsite);\n }\n\n throw new ErrorWithStack(\n `Query: caught unknown error type: ${typeof error}, value: ${error}`,\n callsite,\n );\n};\n\nexport function copyStackTrace(target: unknown, stackTraceSource: Error) {\n if (target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);\n }\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,aAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAyC,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAElC,MAAMG,cAAc,SAASC,KAAK,CAAC;EACxC;EACAC,WAAWA,CAACC,OAA2B,EAAEC,QAAkB,EAAE;IAC3D,KAAK,CAACD,OAAO,CAAC;IACd,IAAIF,KAAK,CAACI,iBAAiB,EAAE;MAC3BJ,KAAK,CAACI,iBAAiB,CAAC,IAAI,EAAED,QAAQ,CAAC;IACzC;EACF;AACF;AAACE,OAAA,CAAAN,cAAA,GAAAA,cAAA;AAEM,MAAMO,mBAAmB,GAAGA,CAGjCC,KAAc,EACdC,IAAa,EACbC,KAAe,KACJ;EACX,IAAIC,YAAoB;EACxB,IAAIH,KAAK,YAAYP,KAAK,EAAE;IAC1B;IACAU,YAAY,GAAGH,KAAK,CAACL,OAAO,CAACS,OAAO,CAAC,kCAAkC,EAAE,EAAE,CAAC;EAC9E,CAAC,MAAM,IAAIJ,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC7CG,YAAY,GAAGH,KAAK,CAACK,QAAQ,CAAC,CAAC;EACjC,CAAC,MAAM;IACLF,YAAY,GAAG,sBAAsB;EACvC;EAEA,IAAIF,IAAI,IAAIC,KAAK,EAAE;IACjBC,YAAY,IAAI,SAASF,IAAI,IAAI,IAAAK,qBAAY,EAACJ,KAAK,EAAE;MAAEK,GAAG,EAAE;IAAK,CAAC,CAAC,EAAE;EACvE;EACA,OAAOJ,YAAY;AACrB,CAAC;;AAED;AAAAL,OAAA,CAAAC,mBAAA,GAAAA,mBAAA;AACO,MAAMS,kBAAkB,GAAGA,CAACR,KAAc,EAAEJ,QAAkB,KAAW;EAC9E,IAAII,KAAK,YAAYP,KAAK,EAAE;IAC1B,IAAIO,KAAK,CAACL,OAAO,CAACc,QAAQ,CAAC,oBAAoB,CAAC,EAAE;MAChD,OAAO,IAAI;IACb;IACA,MAAM,IAAIjB,cAAc,CAACQ,KAAK,CAACL,OAAO,EAAEC,QAAQ,CAAC;EACnD;EAEA,MAAM,IAAIJ,cAAc,CACtB,qCAAqC,OAAOQ,KAAK,YAAYA,KAAK,EAAE,EACpEJ,QACF,CAAC;AACH,CAAC;AAACE,OAAA,CAAAU,kBAAA,GAAAA,kBAAA;AAEK,SAASE,cAAcA,CAACC,MAAe,EAAEC,gBAAuB,EAAE;EACvE,IAAID,MAAM,YAAYlB,KAAK,IAAImB,gBAAgB,CAACC,KAAK,EAAE;IACrDF,MAAM,CAACE,KAAK,GAAGD,gBAAgB,CAACC,KAAK,CAACT,OAAO,CAACQ,gBAAgB,CAACjB,OAAO,EAAEgB,MAAM,CAAChB,OAAO,CAAC;EACzF;AACF","ignoreList":[]}
1
+ {"version":3,"file":"errors.js","names":["ErrorWithStack","Error","constructor","message","callsite","captureStackTrace","exports","copyStackTraceIfNeeded","target","stackTraceSource","stack","replace"],"sources":["../../src/helpers/errors.ts"],"sourcesContent":["export class ErrorWithStack extends Error {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n constructor(message: string | undefined, callsite: Function) {\n super(message);\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, callsite);\n }\n }\n}\n\nexport function copyStackTraceIfNeeded(target: unknown, stackTraceSource: Error | undefined) {\n if (stackTraceSource != null && target instanceof Error && stackTraceSource.stack) {\n target.stack = stackTraceSource.stack.replace(stackTraceSource.message, target.message);\n }\n}\n"],"mappings":";;;;;;;AAAO,MAAMA,cAAc,SAASC,KAAK,CAAC;EACxC;EACAC,WAAWA,CAACC,OAA2B,EAAEC,QAAkB,EAAE;IAC3D,KAAK,CAACD,OAAO,CAAC;IACd,IAAIF,KAAK,CAACI,iBAAiB,EAAE;MAC3BJ,KAAK,CAACI,iBAAiB,CAAC,IAAI,EAAED,QAAQ,CAAC;IACzC;EACF;AACF;AAACE,OAAA,CAAAN,cAAA,GAAAA,cAAA;AAEM,SAASO,sBAAsBA,CAACC,MAAe,EAAEC,gBAAmC,EAAE;EAC3F,IAAIA,gBAAgB,IAAI,IAAI,IAAID,MAAM,YAAYP,KAAK,IAAIQ,gBAAgB,CAACC,KAAK,EAAE;IACjFF,MAAM,CAACE,KAAK,GAAGD,gBAAgB,CAACC,KAAK,CAACC,OAAO,CAACF,gBAAgB,CAACN,OAAO,EAAEK,MAAM,CAACL,OAAO,CAAC;EACzF;AACF","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Validates that no unknown options are passed to a function.
3
+ * Logs a warning if unknown options are found.
4
+ *
5
+ * @param functionName - The name of the function being called (for error messages)
6
+ * @param restOptions - The rest object from destructuring that contains unknown options
7
+ * @param callsite - The function where the validation is called from (e.g., render, renderHook)
8
+ */
9
+ export declare function validateOptions(functionName: string, restOptions: Record<string, unknown>, callsite: Function): void;
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateOptions = validateOptions;
7
+ var _errors = require("./errors");
8
+ var _logger = require("./logger");
9
+ /**
10
+ * Validates that no unknown options are passed to a function.
11
+ * Logs a warning if unknown options are found.
12
+ *
13
+ * @param functionName - The name of the function being called (for error messages)
14
+ * @param restOptions - The rest object from destructuring that contains unknown options
15
+ * @param callsite - The function where the validation is called from (e.g., render, renderHook)
16
+ */
17
+ function validateOptions(functionName, restOptions,
18
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
19
+ callsite) {
20
+ const unknownKeys = Object.keys(restOptions);
21
+ if (unknownKeys.length > 0) {
22
+ // Pass the callsite function (e.g., render) to remove it from stack
23
+ // This leaves only where the user called the function from (e.g., test file)
24
+ const stackTraceError = new _errors.ErrorWithStack('STACK_TRACE_ERROR', callsite);
25
+ const stackLines = stackTraceError.stack ? stackTraceError.stack.split('\n') : [];
26
+ // Skip the first line (Error: STACK_TRACE_ERROR) to show the actual call sites
27
+ // The remaining lines show where the user called the function from
28
+ const stackTrace = stackLines.length > 1 ? `\n\n${stackLines.slice(1).join('\n')}` : '';
29
+ _logger.logger.warn(`Unknown option(s) passed to ${functionName}: ${unknownKeys.join(', ')}${stackTrace}`);
30
+ }
31
+ }
32
+ //# sourceMappingURL=validate-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate-options.js","names":["_errors","require","_logger","validateOptions","functionName","restOptions","callsite","unknownKeys","Object","keys","length","stackTraceError","ErrorWithStack","stackLines","stack","split","stackTrace","slice","join","logger","warn"],"sources":["../../src/helpers/validate-options.ts"],"sourcesContent":["import { ErrorWithStack } from './errors';\nimport { logger } from './logger';\n\n/**\n * Validates that no unknown options are passed to a function.\n * Logs a warning if unknown options are found.\n *\n * @param functionName - The name of the function being called (for error messages)\n * @param restOptions - The rest object from destructuring that contains unknown options\n * @param callsite - The function where the validation is called from (e.g., render, renderHook)\n */\nexport function validateOptions(\n functionName: string,\n restOptions: Record<string, unknown>,\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n callsite: Function,\n): void {\n const unknownKeys = Object.keys(restOptions);\n if (unknownKeys.length > 0) {\n // Pass the callsite function (e.g., render) to remove it from stack\n // This leaves only where the user called the function from (e.g., test file)\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', callsite);\n const stackLines = stackTraceError.stack ? stackTraceError.stack.split('\\n') : [];\n // Skip the first line (Error: STACK_TRACE_ERROR) to show the actual call sites\n // The remaining lines show where the user called the function from\n const stackTrace = stackLines.length > 1 ? `\\n\\n${stackLines.slice(1).join('\\n')}` : '';\n logger.warn(\n `Unknown option(s) passed to ${functionName}: ${unknownKeys.join(', ')}${stackTrace}`,\n );\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,eAAeA,CAC7BC,YAAoB,EACpBC,WAAoC;AACpC;AACAC,QAAkB,EACZ;EACN,MAAMC,WAAW,GAAGC,MAAM,CAACC,IAAI,CAACJ,WAAW,CAAC;EAC5C,IAAIE,WAAW,CAACG,MAAM,GAAG,CAAC,EAAE;IAC1B;IACA;IACA,MAAMC,eAAe,GAAG,IAAIC,sBAAc,CAAC,mBAAmB,EAAEN,QAAQ,CAAC;IACzE,MAAMO,UAAU,GAAGF,eAAe,CAACG,KAAK,GAAGH,eAAe,CAACG,KAAK,CAACC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;IACjF;IACA;IACA,MAAMC,UAAU,GAAGH,UAAU,CAACH,MAAM,GAAG,CAAC,GAAG,OAAOG,UAAU,CAACI,KAAK,CAAC,CAAC,CAAC,CAACC,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE;IACvFC,cAAM,CAACC,IAAI,CACT,+BAA+BhB,YAAY,KAAKG,WAAW,CAACW,IAAI,CAAC,IAAI,CAAC,GAAGF,UAAU,EACrF,CAAC;EACH;AACF","ignoreList":[]}
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.renderHook = renderHook;
7
7
  var React = _interopRequireWildcard(require("react"));
8
+ var _validateOptions = require("./helpers/validate-options");
8
9
  var _render = require("./render");
9
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
11
  async function renderHook(hookToRender, options) {
@@ -20,8 +21,13 @@ async function renderHook(hookToRender, options) {
20
21
  }
21
22
  const {
22
23
  initialProps,
23
- ...renderOptions
24
+ wrapper,
25
+ ...rest
24
26
  } = options ?? {};
27
+ (0, _validateOptions.validateOptions)('renderHook', rest, renderHook);
28
+ const renderOptions = wrapper ? {
29
+ wrapper
30
+ } : {};
25
31
  const {
26
32
  rerender: rerenderComponent,
27
33
  unmount
@@ -1 +1 @@
1
- {"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_render","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderHook","hookToRender","options","result","createRef","HookContainer","hookProps","renderResult","useEffect","current","initialProps","renderOptions","rerender","rerenderComponent","unmount","render","createElement"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { render } from './render';\nimport type { RefObject } from './types';\n\nexport type RenderHookResult<Result, Props> = {\n result: RefObject<Result>;\n rerender: (props: Props) => Promise<void>;\n unmount: () => Promise<void>;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n};\n\nexport async function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): Promise<RenderHookResult<Result, Props>> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function HookContainer({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, ...renderOptions } = options ?? {};\n const { rerender: rerenderComponent, unmount } = await render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it shouldn't be\n <HookContainer hookProps={initialProps} />,\n renderOptions,\n );\n\n return {\n result: result,\n rerender: (hookProps: Props) => rerenderComponent(<HookContainer hookProps={hookProps} />),\n unmount,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAAkC,SAAAD,wBAAAG,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAL,uBAAA,YAAAA,CAAAG,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ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":[]}
1
+ {"version":3,"file":"render-hook.js","names":["React","_interopRequireWildcard","require","_validateOptions","_render","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","renderHook","hookToRender","options","result","createRef","HookContainer","hookProps","renderResult","useEffect","current","initialProps","wrapper","rest","validateOptions","renderOptions","rerender","rerenderComponent","unmount","render","createElement"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { validateOptions } from './helpers/validate-options';\nimport { render } from './render';\nimport type { RefObject } from './types';\n\nexport type RenderHookResult<Result, Props> = {\n result: RefObject<Result>;\n rerender: (props: Props) => Promise<void>;\n unmount: () => Promise<void>;\n};\n\nexport type RenderHookOptions<Props> = {\n /**\n * The initial props to pass to the hook.\n */\n initialProps?: Props;\n\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n};\n\nexport async function renderHook<Result, Props>(\n hookToRender: (props: Props) => Result,\n options?: RenderHookOptions<NoInfer<Props>>,\n): Promise<RenderHookResult<Result, Props>> {\n const result = React.createRef<Result>() as RefObject<Result>;\n\n function HookContainer({ hookProps }: { hookProps: Props }) {\n const renderResult = hookToRender(hookProps);\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { initialProps, wrapper, ...rest } = options ?? {};\n validateOptions('renderHook', rest, renderHook);\n const renderOptions = wrapper ? { wrapper } : {};\n const { rerender: rerenderComponent, unmount } = await render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it shouldn't be\n <HookContainer hookProps={initialProps} />,\n renderOptions,\n );\n\n return {\n result: result,\n rerender: (hookProps: Props) => rerenderComponent(<HookContainer hookProps={hookProps} />),\n unmount,\n };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;A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S,CAAC;IAC5C9B,KAAK,CAACgC,SAAS,CAAC,MAAM;MACpBL,MAAM,CAACM,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,YAAY;IAAEC,OAAO;IAAE,GAAGC;EAAK,CAAC,GAAGV,OAAO,IAAI,CAAC,CAAC;EACxD,IAAAW,gCAAe,EAAC,YAAY,EAAED,IAAI,EAAEZ,UAAU,CAAC;EAC/C,MAAMc,aAAa,GAAGH,OAAO,GAAG;IAAEA;EAAQ,CAAC,GAAG,CAAC,CAAC;EAChD,MAAM;IAAEI,QAAQ,EAAEC,iBAAiB;IAAEC;EAAQ,CAAC,GAAG,MAAM,IAAAC,cAAM;EAAA;EAC3D;EACA1C,KAAA,CAAA2C,aAAA,CAACd,aAAa;IAACC,SAAS,EAAEI;EAAa,CAAE,CAAC,EAC1CI,aACF,CAAC;EAED,OAAO;IACLX,MAAM,EAAEA,MAAM;IACdY,QAAQ,EAAGT,SAAgB,IAAKU,iBAAiB,cAACxC,KAAA,CAAA2C,aAAA,CAACd,aAAa;MAACC,SAAS,EAAEA;IAAU,CAAE,CAAC,CAAC;IAC1FW;EACF,CAAC;AACH","ignoreList":[]}
package/build/render.d.ts CHANGED
@@ -11,7 +11,7 @@ export interface RenderOptions {
11
11
  }
12
12
  export type RenderResult = Awaited<ReturnType<typeof render>>;
13
13
  /**
14
- * Renders test component deeply using React Test Renderer and exposes helpers
14
+ * Renders test component deeply using Test Renderer and exposes helpers
15
15
  * to assert on the output.
16
16
  */
17
17
  export declare function render<T>(element: React.ReactElement<T>, options?: RenderOptions): Promise<{
package/build/render.js CHANGED
@@ -11,18 +11,21 @@ var _cleanup = require("./cleanup");
11
11
  var _config = require("./config");
12
12
  var _debug = require("./helpers/debug");
13
13
  var _hostComponentNames = require("./helpers/host-component-names");
14
+ var _validateOptions = require("./helpers/validate-options");
14
15
  var _screen = require("./screen");
15
16
  var _within = require("./within");
16
17
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
17
18
  /**
18
- * Renders test component deeply using React Test Renderer and exposes helpers
19
+ * Renders test component deeply using Test Renderer and exposes helpers
19
20
  * to assert on the output.
20
21
  */
21
22
  async function render(element, options = {}) {
22
23
  const {
23
24
  wrapper: Wrapper,
24
- createNodeMock
25
+ createNodeMock,
26
+ ...rest
25
27
  } = options || {};
28
+ (0, _validateOptions.validateOptions)('render', rest, render);
26
29
  const rendererOptions = {
27
30
  textComponentTypes: _hostComponentNames.HOST_TEXT_NAMES,
28
31
  publicTextComponentTypes: ['Text'],
@@ -46,11 +49,10 @@ async function render(element, options = {}) {
46
49
  };
47
50
  const toJSON = () => {
48
51
  const json = renderer.container.toJSON();
49
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
50
52
  if (json?.children.length === 0) {
51
53
  return null;
52
54
  }
53
- if (json?.children?.length === 1 && typeof json.children[0] !== 'string') {
55
+ if (json?.children.length === 1 && typeof json.children[0] !== 'string') {
54
56
  return json.children[0];
55
57
  }
56
58
  return json;
@@ -1 +1 @@
1
- {"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","createNodeMock","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForElement","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n createRoot,\n type HostElement,\n type JsonElement,\n type Root,\n type RootOptions,\n} from 'test-renderer';\n\nimport { act } from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { HOST_TEXT_NAMES } from './helpers/host-component-names';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n createNodeMock?: (element: React.ReactElement) => object;\n}\n\nexport type RenderResult = Awaited<ReturnType<typeof render>>;\n\n/**\n * Renders test component deeply using React Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {\n const { wrapper: Wrapper, createNodeMock } = options || {};\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n createNodeMock,\n };\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = createRoot(rendererOptions);\n\n await act(() => {\n renderer.render(wrap(element));\n });\n\n const container = renderer.container;\n\n const rerender = async (component: React.ReactElement) => {\n await act(() => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = async () => {\n await act(() => {\n renderer.unmount();\n });\n };\n\n const toJSON = (): JsonElement | null => {\n const json = renderer.container.toJSON();\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n if (json?.children!.length === 0) {\n return null;\n }\n\n if (json?.children?.length === 1 && typeof json.children[0] !== 'string') {\n return json.children[0];\n }\n\n return json;\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(renderer.container),\n rerender,\n unmount,\n toJSON,\n debug: makeDebug(renderer),\n get container(): HostElement {\n return renderer.container;\n },\n get root(): HostElement | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n /* istanbul ignore next */\n throw new Error(\n 'Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.',\n );\n }\n\n return firstChild;\n },\n };\n\n setRenderResult(result);\n\n return result;\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: Root): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...defaultDebugOptions, ...options };\n const json = renderer.container.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,OAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AAAgD,SAAAD,wBAAAU,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAZ,uBAAA,YAAAA,CAAAU,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ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C;MACH;MAEA,OAAOD,UAAU;IACnB;EACF,CAAC;EAED,IAAAE,uBAAe,EAACP,MAAM,CAAC;EAEvB,OAAOA,MAAM;AACf;AAIA,SAASG,SAASA,CAACf,QAAc,EAAiB;EAChD,SAASoB,SAASA,CAAC9B,OAAsB,EAAE;IACzC,MAAM;MAAE+B;IAAoB,CAAC,GAAG,IAAAC,iBAAS,EAAC,CAAC;IAC3C,MAAMC,YAAY,GAAG;MAAE,GAAGF,mBAAmB;MAAE,GAAG/B;IAAQ,CAAC;IAC3D,MAAMkB,IAAI,GAAGR,QAAQ,CAACG,SAAS,CAACI,MAAM,CAAC,CAAC;IACxC,IAAIC,IAAI,EAAE;MACR,OAAO,IAAAM,YAAK,EAACN,IAAI,EAAEe,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
1
+ {"version":3,"file":"render.js","names":["React","_interopRequireWildcard","require","_testRenderer","_act","_cleanup","_config","_debug","_hostComponentNames","_validateOptions","_screen","_within","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","render","element","options","wrapper","Wrapper","createNodeMock","rest","validateOptions","rendererOptions","textComponentTypes","HOST_TEXT_NAMES","publicTextComponentTypes","wrap","createElement","renderer","createRoot","act","container","rerender","component","unmount","toJSON","json","children","length","addToCleanupQueue","result","getQueriesForElement","debug","makeDebug","root","firstChild","Error","setRenderResult","debugImpl","defaultDebugOptions","getConfig","debugOptions"],"sources":["../src/render.tsx"],"sourcesContent":["import * as React from 'react';\nimport {\n createRoot,\n type HostElement,\n type JsonElement,\n type Root,\n type RootOptions,\n} from 'test-renderer';\n\nimport { act } from './act';\nimport { addToCleanupQueue } from './cleanup';\nimport { getConfig } from './config';\nimport type { DebugOptions } from './helpers/debug';\nimport { debug } from './helpers/debug';\nimport { HOST_TEXT_NAMES } from './helpers/host-component-names';\nimport { validateOptions } from './helpers/validate-options';\nimport { setRenderResult } from './screen';\nimport { getQueriesForElement } from './within';\n\nexport interface RenderOptions {\n /**\n * Pass a React Component as the wrapper option to have it rendered around the inner element. This is most useful for creating\n * reusable custom render functions for common data providers.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n wrapper?: React.ComponentType<any>;\n\n createNodeMock?: (element: React.ReactElement) => object;\n}\n\nexport type RenderResult = Awaited<ReturnType<typeof render>>;\n\n/**\n * Renders test component deeply using Test Renderer and exposes helpers\n * to assert on the output.\n */\nexport async function render<T>(element: React.ReactElement<T>, options: RenderOptions = {}) {\n const { wrapper: Wrapper, createNodeMock, ...rest } = options || {};\n validateOptions('render', rest, render);\n\n const rendererOptions: RootOptions = {\n textComponentTypes: HOST_TEXT_NAMES,\n publicTextComponentTypes: ['Text'],\n createNodeMock,\n };\n\n const wrap = (element: React.ReactElement) => (Wrapper ? <Wrapper>{element}</Wrapper> : element);\n const renderer = createRoot(rendererOptions);\n\n await act(() => {\n renderer.render(wrap(element));\n });\n\n const container = renderer.container;\n\n const rerender = async (component: React.ReactElement) => {\n await act(() => {\n renderer.render(wrap(component));\n });\n };\n\n const unmount = async () => {\n await act(() => {\n renderer.unmount();\n });\n };\n\n const toJSON = (): JsonElement | null => {\n const json = renderer.container.toJSON();\n if (json?.children.length === 0) {\n return null;\n }\n\n if (json?.children.length === 1 && typeof json.children[0] !== 'string') {\n return json.children[0];\n }\n\n return json;\n };\n\n addToCleanupQueue(unmount);\n\n const result = {\n ...getQueriesForElement(renderer.container),\n rerender,\n unmount,\n toJSON,\n debug: makeDebug(renderer),\n get container(): HostElement {\n return renderer.container;\n },\n get root(): HostElement | null {\n const firstChild = container.children[0];\n if (typeof firstChild === 'string') {\n /* istanbul ignore next */\n throw new Error(\n 'Invariant Violation: Root element must be a host element. Detected attempt to render a string within the root element.',\n );\n }\n\n return firstChild;\n },\n };\n\n setRenderResult(result);\n\n return result;\n}\n\nexport type DebugFunction = (options?: DebugOptions) => void;\n\nfunction makeDebug(renderer: Root): DebugFunction {\n function debugImpl(options?: DebugOptions) {\n const { defaultDebugOptions } = getConfig();\n const debugOptions = { ...defaultDebugOptions, ...options };\n const json = renderer.container.toJSON();\n if (json) {\n return debug(json, debugOptions);\n }\n }\n return debugImpl;\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,aAAA,GAAAD,OAAA;AAQA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,mBAAA,GAAAN,OAAA;AACA,IAAAO,gBAAA,GAAAP,OAAA;AACA,IAAAQ,OAAA,GAAAR,OAAA;AACA,IAAAS,OAAA,GAAAT,OAAA;AAAgD,SAAAD,wBAAAW,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAb,uBAAA,YAAAA,CAAAW,CAAA,EAAAC,CAAA,SAAAA,CAAA,IAAAD,CAAA,IAAAA,CAAA,CAAAK,UAAA,SAAAL,CAAA,MAAAM,CAAA,EAAAC,CAAA,EAAAC,CAAA,KAAAC,SAAA,QAAAC,OAAA,EAAAV,CAAA,iBAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,SAAAQ,CAAA,MAAAF,CAAA,GAAAL,CAAA,GAAAG,CAAA,GAAAD,CAAA,QAAAG,CAAA,CAAAK,GAAA,CAAAX,CAAA,UAAAM,CAAA,CAAAM,GAAA,CAAAZ,CAAA,GAAAM,CAAA,CAAAO,GAAA,CAAAb,CAAA,EAAAQ,CAAA,gBAAAP,CAAA,IAAAD,CAAA,gBAAAC,CAAA,OAAAa,cAAA,CAAAC,IAAA,CAAAf,CAAA,EAAAC,CAAA,OAAAM,CAAA,IAAAD,CAAA,GAAAU,MAAA,CAAAC,cAAA,KAAAD,MAAA,CAAAE,wBAAA,CAAAlB,C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,GAAGjC;IAAQ,CAAC;IAC3D,MAAMoB,IAAI,GAAGR,QAAQ,CAACG,SAAS,CAACI,MAAM,CAAC,CAAC;IACxC,IAAIC,IAAI,EAAE;MACR,OAAO,IAAAM,YAAK,EAACN,IAAI,EAAEe,YAAY,CAAC;IAClC;EACF;EACA,OAAOH,SAAS;AAClB","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ export type TimerType = 'real' | 'fake' | 'fake-legacy';
2
+ export declare function setupTimeType(type: TimerType): void;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setupTimeType = setupTimeType;
7
+ function setupTimeType(type) {
8
+ if (type === 'fake-legacy') {
9
+ jest.useFakeTimers({
10
+ legacyFakeTimers: true
11
+ });
12
+ } else if (type === 'fake') {
13
+ jest.useFakeTimers({
14
+ legacyFakeTimers: false
15
+ });
16
+ } else {
17
+ jest.useRealTimers();
18
+ }
19
+ }
20
+ //# sourceMappingURL=timers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"timers.js","names":["setupTimeType","type","jest","useFakeTimers","legacyFakeTimers","useRealTimers"],"sources":["../../src/test-utils/timers.ts"],"sourcesContent":["export type TimerType = 'real' | 'fake' | 'fake-legacy';\n\nexport function setupTimeType(type: TimerType): void {\n if (type === 'fake-legacy') {\n jest.useFakeTimers({ legacyFakeTimers: true });\n } else if (type === 'fake') {\n jest.useFakeTimers({ legacyFakeTimers: false });\n } else {\n jest.useRealTimers();\n }\n}\n"],"mappings":";;;;;;AAEO,SAASA,aAAaA,CAACC,IAAe,EAAQ;EACnD,IAAIA,IAAI,KAAK,aAAa,EAAE;IAC1BC,IAAI,CAACC,aAAa,CAAC;MAAEC,gBAAgB,EAAE;IAAK,CAAC,CAAC;EAChD,CAAC,MAAM,IAAIH,IAAI,KAAK,MAAM,EAAE;IAC1BC,IAAI,CAACC,aAAa,CAAC;MAAEC,gBAAgB,EAAE;IAAM,CAAC,CAAC;EACjD,CAAC,MAAM;IACLF,IAAI,CAACG,aAAa,CAAC,CAAC;EACtB;AACF","ignoreList":[]}
@@ -1 +1 @@
1
- {"root":["../src/act.ts","../src/cleanup.ts","../src/config.ts","../src/event-handler.ts","../src/fire-event.ts","../src/flush-micro-tasks.ts","../src/index.ts","../src/matches.ts","../src/native-state.ts","../src/pure.ts","../src/react-versions.ts","../src/render-hook.tsx","../src/render.tsx","../src/screen.ts","../src/types.ts","../src/wait-for-element-to-be-removed.ts","../src/wait-for.ts","../src/within.ts","../src/helpers/accessibility.ts","../src/helpers/component-tree.ts","../src/helpers/debug.ts","../src/helpers/errors.ts","../src/helpers/find-all.ts","../src/helpers/format-element.ts","../src/helpers/host-component-names.ts","../src/helpers/logger.ts","../src/helpers/map-props.ts","../src/helpers/object.ts","../src/helpers/pointer-events.ts","../src/helpers/text-content.ts","../src/helpers/text-input.ts","../src/helpers/timers.ts","../src/helpers/wrap-async.ts","../src/helpers/matchers/match-accessibility-state.ts","../src/helpers/matchers/match-accessibility-value.ts","../src/helpers/matchers/match-array-prop.ts","../src/helpers/matchers/match-label-text.ts","../src/helpers/matchers/match-object-prop.ts","../src/helpers/matchers/match-string-prop.ts","../src/helpers/matchers/match-text-content.ts","../src/matchers/extend-expect.ts","../src/matchers/index.ts","../src/matchers/to-be-busy.ts","../src/matchers/to-be-checked.ts","../src/matchers/to-be-disabled.ts","../src/matchers/to-be-empty-element.ts","../src/matchers/to-be-expanded.ts","../src/matchers/to-be-on-the-screen.ts","../src/matchers/to-be-partially-checked.ts","../src/matchers/to-be-selected.ts","../src/matchers/to-be-visible.ts","../src/matchers/to-contain-element.ts","../src/matchers/to-have-accessibility-value.ts","../src/matchers/to-have-accessible-name.ts","../src/matchers/to-have-display-value.ts","../src/matchers/to-have-prop.ts","../src/matchers/to-have-style.ts","../src/matchers/to-have-text-content.ts","../src/matchers/types.ts","../src/matchers/utils.ts","../src/queries/display-value.ts","../src/queries/hint-text.ts","../src/queries/label-text.ts","../src/queries/make-queries.ts","../src/queries/options.ts","../src/queries/placeholder-text.ts","../src/queries/role.ts","../src/queries/test-id.ts","../src/queries/text.ts","../src/test-utils/console.ts","../src/test-utils/events.ts","../src/test-utils/json.ts","../src/test-utils/version.ts","../src/user-event/clear.ts","../src/user-event/index.ts","../src/user-event/paste.ts","../src/user-event/event-builder/base.ts","../src/user-event/event-builder/common.ts","../src/user-event/event-builder/index.ts","../src/user-event/event-builder/scroll-view.ts","../src/user-event/event-builder/text-input.ts","../src/user-event/press/index.ts","../src/user-event/press/press.ts","../src/user-event/scroll/index.ts","../src/user-event/scroll/scroll-to.ts","../src/user-event/scroll/utils.ts","../src/user-event/setup/index.ts","../src/user-event/setup/setup.ts","../src/user-event/type/index.ts","../src/user-event/type/parse-keys.ts","../src/user-event/type/type.ts","../src/user-event/utils/content-size.ts","../src/user-event/utils/dispatch-event.ts","../src/user-event/utils/index.ts","../src/user-event/utils/text-range.ts","../src/user-event/utils/wait.ts"],"version":"5.9.3"}
1
+ {"root":["../src/act.ts","../src/cleanup.ts","../src/config.ts","../src/event-handler.ts","../src/fire-event.ts","../src/flush-micro-tasks.ts","../src/index.ts","../src/matches.ts","../src/native-state.ts","../src/pure.ts","../src/render-hook.tsx","../src/render.tsx","../src/screen.ts","../src/types.ts","../src/wait-for-element-to-be-removed.ts","../src/wait-for.ts","../src/within.ts","../src/helpers/accessibility.ts","../src/helpers/component-tree.ts","../src/helpers/debug.ts","../src/helpers/errors.ts","../src/helpers/find-all.ts","../src/helpers/format-element.ts","../src/helpers/host-component-names.ts","../src/helpers/logger.ts","../src/helpers/map-props.ts","../src/helpers/object.ts","../src/helpers/pointer-events.ts","../src/helpers/text-content.ts","../src/helpers/text-input.ts","../src/helpers/timers.ts","../src/helpers/validate-options.ts","../src/helpers/wrap-async.ts","../src/helpers/matchers/match-accessibility-state.ts","../src/helpers/matchers/match-accessibility-value.ts","../src/helpers/matchers/match-array-prop.ts","../src/helpers/matchers/match-label-text.ts","../src/helpers/matchers/match-object-prop.ts","../src/helpers/matchers/match-string-prop.ts","../src/helpers/matchers/match-text-content.ts","../src/matchers/extend-expect.ts","../src/matchers/index.ts","../src/matchers/to-be-busy.ts","../src/matchers/to-be-checked.ts","../src/matchers/to-be-disabled.ts","../src/matchers/to-be-empty-element.ts","../src/matchers/to-be-expanded.ts","../src/matchers/to-be-on-the-screen.ts","../src/matchers/to-be-partially-checked.ts","../src/matchers/to-be-selected.ts","../src/matchers/to-be-visible.ts","../src/matchers/to-contain-element.ts","../src/matchers/to-have-accessibility-value.ts","../src/matchers/to-have-accessible-name.ts","../src/matchers/to-have-display-value.ts","../src/matchers/to-have-prop.ts","../src/matchers/to-have-style.ts","../src/matchers/to-have-text-content.ts","../src/matchers/types.ts","../src/matchers/utils.ts","../src/queries/display-value.ts","../src/queries/hint-text.ts","../src/queries/label-text.ts","../src/queries/make-queries.ts","../src/queries/options.ts","../src/queries/placeholder-text.ts","../src/queries/role.ts","../src/queries/test-id.ts","../src/queries/text.ts","../src/test-utils/console.ts","../src/test-utils/events.ts","../src/test-utils/json.ts","../src/test-utils/timers.ts","../src/test-utils/version.ts","../src/user-event/clear.ts","../src/user-event/index.ts","../src/user-event/paste.ts","../src/user-event/event-builder/base.ts","../src/user-event/event-builder/common.ts","../src/user-event/event-builder/index.ts","../src/user-event/event-builder/scroll-view.ts","../src/user-event/event-builder/text-input.ts","../src/user-event/press/index.ts","../src/user-event/press/press.ts","../src/user-event/scroll/index.ts","../src/user-event/scroll/scroll-to.ts","../src/user-event/scroll/utils.ts","../src/user-event/setup/index.ts","../src/user-event/setup/setup.ts","../src/user-event/type/index.ts","../src/user-event/type/parse-keys.ts","../src/user-event/type/type.ts","../src/user-event/utils/content-size.ts","../src/user-event/utils/dispatch-event.ts","../src/user-event/utils/index.ts","../src/user-event/utils/text-range.ts","../src/user-event/utils/wait.ts"],"version":"5.9.3"}
@@ -1,3 +1,7 @@
1
1
  import type { BaseSyntheticEvent } from 'react';
2
2
  /** Builds base syntentic event stub, with prop values as inspected in RN runtime. */
3
- export declare function baseSyntheticEvent(): Partial<BaseSyntheticEvent<object, unknown, unknown>>;
3
+ type BaseEvent = Partial<BaseSyntheticEvent<object, unknown, unknown>> & {
4
+ isPersistent: () => boolean;
5
+ };
6
+ export declare function baseSyntheticEvent(): BaseEvent;
7
+ export {};
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.baseSyntheticEvent = baseSyntheticEvent;
7
7
  /** Builds base syntentic event stub, with prop values as inspected in RN runtime. */
8
+
8
9
  function baseSyntheticEvent() {
9
10
  return {
10
11
  currentTarget: {},
@@ -14,7 +15,6 @@ function baseSyntheticEvent() {
14
15
  stopPropagation: () => {},
15
16
  isPropagationStopped: () => false,
16
17
  persist: () => {},
17
- // @ts-expect-error: `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods
18
18
  isPersistent: () => false,
19
19
  timeStamp: 0
20
20
  };
@@ -1 +1 @@
1
- {"version":3,"file":"base.js","names":["baseSyntheticEvent","currentTarget","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","persist","isPersistent","timeStamp"],"sources":["../../../src/user-event/event-builder/base.ts"],"sourcesContent":["import type { BaseSyntheticEvent } from 'react';\n\n/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */\nexport function baseSyntheticEvent(): Partial<BaseSyntheticEvent<object, unknown, unknown>> {\n return {\n currentTarget: {},\n target: {},\n preventDefault: () => {},\n isDefaultPrevented: () => false,\n stopPropagation: () => {},\n isPropagationStopped: () => false,\n persist: () => {},\n // @ts-expect-error: `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods\n isPersistent: () => false,\n timeStamp: 0,\n };\n}\n"],"mappings":";;;;;;AAEA;AACO,SAASA,kBAAkBA,CAAA,EAA0D;EAC1F,OAAO;IACLC,aAAa,EAAE,CAAC,CAAC;IACjBC,MAAM,EAAE,CAAC,CAAC;IACVC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;IACxBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;IAC/BC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;IACzBC,oBAAoB,EAAEA,CAAA,KAAM,KAAK;IACjCC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;IACjB;IACAC,YAAY,EAAEA,CAAA,KAAM,KAAK;IACzBC,SAAS,EAAE;EACb,CAAC;AACH","ignoreList":[]}
1
+ {"version":3,"file":"base.js","names":["baseSyntheticEvent","currentTarget","target","preventDefault","isDefaultPrevented","stopPropagation","isPropagationStopped","persist","isPersistent","timeStamp"],"sources":["../../../src/user-event/event-builder/base.ts"],"sourcesContent":["import type { BaseSyntheticEvent } from 'react';\n\n/** Builds base syntentic event stub, with prop values as inspected in RN runtime. */\ntype BaseEvent = Partial<BaseSyntheticEvent<object, unknown, unknown>> & {\n // `isPersistent` is not a standard prop, but it's used in RN runtime. See: https://react.dev/reference/react-dom/components/common#react-event-object-methods\n isPersistent: () => boolean;\n};\n\nexport function baseSyntheticEvent(): BaseEvent {\n return {\n currentTarget: {},\n target: {},\n preventDefault: () => {},\n isDefaultPrevented: () => false,\n stopPropagation: () => {},\n isPropagationStopped: () => false,\n persist: () => {},\n isPersistent: () => false,\n timeStamp: 0,\n };\n}\n"],"mappings":";;;;;;AAEA;;AAMO,SAASA,kBAAkBA,CAAA,EAAc;EAC9C,OAAO;IACLC,aAAa,EAAE,CAAC,CAAC;IACjBC,MAAM,EAAE,CAAC,CAAC;IACVC,cAAc,EAAEA,CAAA,KAAM,CAAC,CAAC;IACxBC,kBAAkB,EAAEA,CAAA,KAAM,KAAK;IAC/BC,eAAe,EAAEA,CAAA,KAAM,CAAC,CAAC;IACzBC,oBAAoB,EAAEA,CAAA,KAAM,KAAK;IACjCC,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;IACjBC,YAAY,EAAEA,CAAA,KAAM,KAAK;IACzBC,SAAS,EAAE;EACb,CAAC;AACH","ignoreList":[]}
@@ -31,6 +31,7 @@ declare function touch(): {
31
31
  persist?: (() => void) | undefined;
32
32
  timeStamp?: number | undefined;
33
33
  type?: string | undefined;
34
+ isPersistent: () => boolean;
34
35
  };
35
36
  export declare const CommonEventBuilder: {
36
37
  touch: typeof touch;
@@ -65,6 +66,7 @@ export declare const CommonEventBuilder: {
65
66
  persist?: (() => void) | undefined;
66
67
  timeStamp?: number | undefined;
67
68
  type?: string | undefined;
69
+ isPersistent: () => boolean;
68
70
  };
69
71
  responderRelease: () => {
70
72
  dispatchConfig: {
@@ -97,6 +99,7 @@ export declare const CommonEventBuilder: {
97
99
  persist?: (() => void) | undefined;
98
100
  timeStamp?: number | undefined;
99
101
  type?: string | undefined;
102
+ isPersistent: () => boolean;
100
103
  };
101
104
  /**
102
105
  * Experimental values:
@@ -121,6 +124,7 @@ export declare const CommonEventBuilder: {
121
124
  persist?: (() => void) | undefined;
122
125
  timeStamp?: number | undefined;
123
126
  type?: string | undefined;
127
+ isPersistent: () => boolean;
124
128
  };
125
129
  /**
126
130
  * Experimental values:
@@ -145,6 +149,7 @@ export declare const CommonEventBuilder: {
145
149
  persist?: (() => void) | undefined;
146
150
  timeStamp?: number | undefined;
147
151
  type?: string | undefined;
152
+ isPersistent: () => boolean;
148
153
  };
149
154
  };
150
155
  export {};
@@ -28,6 +28,7 @@ export declare const EventBuilder: {
28
28
  persist?: (() => void) | undefined;
29
29
  timeStamp?: number | undefined;
30
30
  type?: string | undefined;
31
+ isPersistent: () => boolean;
31
32
  };
32
33
  responderGrant: () => {
33
34
  dispatchConfig: {
@@ -60,6 +61,7 @@ export declare const EventBuilder: {
60
61
  persist?: (() => void) | undefined;
61
62
  timeStamp?: number | undefined;
62
63
  type?: string | undefined;
64
+ isPersistent: () => boolean;
63
65
  };
64
66
  responderRelease: () => {
65
67
  dispatchConfig: {
@@ -92,6 +94,7 @@ export declare const EventBuilder: {
92
94
  persist?: (() => void) | undefined;
93
95
  timeStamp?: number | undefined;
94
96
  type?: string | undefined;
97
+ isPersistent: () => boolean;
95
98
  };
96
99
  focus: () => {
97
100
  nativeEvent: {
@@ -111,6 +114,7 @@ export declare const EventBuilder: {
111
114
  persist?: (() => void) | undefined;
112
115
  timeStamp?: number | undefined;
113
116
  type?: string | undefined;
117
+ isPersistent: () => boolean;
114
118
  };
115
119
  blur: () => {
116
120
  nativeEvent: {
@@ -130,6 +134,7 @@ export declare const EventBuilder: {
130
134
  persist?: (() => void) | undefined;
131
135
  timeStamp?: number | undefined;
132
136
  type?: string | undefined;
137
+ isPersistent: () => boolean;
133
138
  };
134
139
  };
135
140
  ScrollView: {
@@ -174,6 +179,7 @@ export declare const EventBuilder: {
174
179
  persist?: (() => void) | undefined;
175
180
  timeStamp?: number | undefined;
176
181
  type?: string | undefined;
182
+ isPersistent: () => boolean;
177
183
  };
178
184
  };
179
185
  TextInput: {
@@ -197,6 +203,7 @@ export declare const EventBuilder: {
197
203
  persist?: (() => void) | undefined;
198
204
  timeStamp?: number | undefined;
199
205
  type?: string | undefined;
206
+ isPersistent: () => boolean;
200
207
  };
201
208
  keyPress: (key: string) => {
202
209
  nativeEvent: {
@@ -216,6 +223,7 @@ export declare const EventBuilder: {
216
223
  persist?: (() => void) | undefined;
217
224
  timeStamp?: number | undefined;
218
225
  type?: string | undefined;
226
+ isPersistent: () => boolean;
219
227
  };
220
228
  submitEditing: (text: string) => {
221
229
  nativeEvent: {
@@ -236,6 +244,7 @@ export declare const EventBuilder: {
236
244
  persist?: (() => void) | undefined;
237
245
  timeStamp?: number | undefined;
238
246
  type?: string | undefined;
247
+ isPersistent: () => boolean;
239
248
  };
240
249
  endEditing: (text: string) => {
241
250
  nativeEvent: {
@@ -256,6 +265,7 @@ export declare const EventBuilder: {
256
265
  persist?: (() => void) | undefined;
257
266
  timeStamp?: number | undefined;
258
267
  type?: string | undefined;
268
+ isPersistent: () => boolean;
259
269
  };
260
270
  selectionChange: ({ start, end }: import("../utils").TextRange) => {
261
271
  nativeEvent: {
@@ -278,6 +288,7 @@ export declare const EventBuilder: {
278
288
  persist?: (() => void) | undefined;
279
289
  timeStamp?: number | undefined;
280
290
  type?: string | undefined;
291
+ isPersistent: () => boolean;
281
292
  };
282
293
  contentSizeChange: ({ width, height }: import("../../types").Size) => {
283
294
  nativeEvent: {
@@ -301,6 +312,7 @@ export declare const EventBuilder: {
301
312
  persist?: (() => void) | undefined;
302
313
  timeStamp?: number | undefined;
303
314
  type?: string | undefined;
315
+ isPersistent: () => boolean;
304
316
  };
305
317
  };
306
318
  };
@@ -53,5 +53,6 @@ export declare const ScrollViewEventBuilder: {
53
53
  persist?: (() => void) | undefined;
54
54
  timeStamp?: number | undefined;
55
55
  type?: string | undefined;
56
+ isPersistent: () => boolean;
56
57
  };
57
58
  };
@@ -26,6 +26,7 @@ export declare const TextInputEventBuilder: {
26
26
  persist?: (() => void) | undefined;
27
27
  timeStamp?: number | undefined;
28
28
  type?: string | undefined;
29
+ isPersistent: () => boolean;
29
30
  };
30
31
  /**
31
32
  * Experimental values:
@@ -50,6 +51,7 @@ export declare const TextInputEventBuilder: {
50
51
  persist?: (() => void) | undefined;
51
52
  timeStamp?: number | undefined;
52
53
  type?: string | undefined;
54
+ isPersistent: () => boolean;
53
55
  };
54
56
  /**
55
57
  * Experimental values:
@@ -75,6 +77,7 @@ export declare const TextInputEventBuilder: {
75
77
  persist?: (() => void) | undefined;
76
78
  timeStamp?: number | undefined;
77
79
  type?: string | undefined;
80
+ isPersistent: () => boolean;
78
81
  };
79
82
  /**
80
83
  * Experimental values:
@@ -100,6 +103,7 @@ export declare const TextInputEventBuilder: {
100
103
  persist?: (() => void) | undefined;
101
104
  timeStamp?: number | undefined;
102
105
  type?: string | undefined;
106
+ isPersistent: () => boolean;
103
107
  };
104
108
  /**
105
109
  * Experimental values:
@@ -127,6 +131,7 @@ export declare const TextInputEventBuilder: {
127
131
  persist?: (() => void) | undefined;
128
132
  timeStamp?: number | undefined;
129
133
  type?: string | undefined;
134
+ isPersistent: () => boolean;
130
135
  };
131
136
  /**
132
137
  * Experimental values:
@@ -155,5 +160,6 @@ export declare const TextInputEventBuilder: {
155
160
  persist?: (() => void) | undefined;
156
161
  timeStamp?: number | undefined;
157
162
  type?: string | undefined;
163
+ isPersistent: () => boolean;
158
164
  };
159
165
  };
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.setup = setup;
7
7
  var _timers = require("../../helpers/timers");
8
+ var _validateOptions = require("../../helpers/validate-options");
8
9
  var _wrapAsync = require("../../helpers/wrap-async");
9
10
  var _clear = require("../clear");
10
11
  var _paste = require("../paste");
@@ -34,7 +35,7 @@ const defaultOptions = {
34
35
  * @returns UserEvent instance
35
36
  */
36
37
  function setup(options) {
37
- const config = createConfig(options);
38
+ const config = createConfig(options, setup);
38
39
  const instance = createInstance(config);
39
40
  return instance;
40
41
  }
@@ -46,10 +47,23 @@ function setup(options) {
46
47
  * @param advanceTimers function to be called to advance fake timers
47
48
  */
48
49
 
49
- function createConfig(options) {
50
+ function createConfig(options = {},
51
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
52
+ callsite) {
53
+ const {
54
+ delay,
55
+ advanceTimers,
56
+ ...rest
57
+ } = options;
58
+ (0, _validateOptions.validateOptions)('userEvent.setup', rest, callsite);
50
59
  return {
51
60
  ...defaultOptions,
52
- ...options
61
+ ...(delay !== undefined && {
62
+ delay
63
+ }),
64
+ ...(advanceTimers !== undefined && {
65
+ advanceTimers
66
+ })
53
67
  };
54
68
  }
55
69
 
@@ -1 +1 @@
1
- {"version":3,"file":"setup.js","names":["_timers","require","_wrapAsync","_clear","_paste","_press","_scroll","_type","_utils","universalJestAdvanceTimersBy","ms","jestFakeTimersAreEnabled","jest","advanceTimersByTime","Promise","resolve","defaultOptions","delay","advanceTimers","setup","options","config","createConfig","instance","createInstance","api","press","wrapAndBindImpl","longPress","type","clear","paste","scrollTo","Object","assign","impl","method","args","wrapAsync","apply","then","result","wait","defineProperty","get","name"],"sources":["../../../src/user-event/setup/setup.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport { jestFakeTimersAreEnabled } from '../../helpers/timers';\nimport { wrapAsync } from '../../helpers/wrap-async';\nimport { clear } from '../clear';\nimport { paste } from '../paste';\nimport type { PressOptions } from '../press';\nimport { longPress, press } from '../press';\nimport type { ScrollToOptions } from '../scroll';\nimport { scrollTo } from '../scroll';\nimport type { TypeOptions } from '../type';\nimport { type } from '../type';\nimport { wait } from '../utils';\n\nexport interface UserEventSetupOptions {\n /**\n * Between some subsequent inputs like typing a series of characters\n * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.\n * This moves the next changes at least to next macro task\n * and allows other (asynchronous) code to run between events.\n *\n * `null` prevents `setTimeout` from being called.\n *\n * @default 0\n */\n delay?: number;\n\n /**\n * Function to be called to advance fake timers. Setting it is necessary for\n * fake timers to work.\n *\n * @example jest.advanceTimersByTime\n */\n advanceTimers?: (delay: number) => Promise<void> | void;\n}\n\n/**\n * This functions allow wait to work correctly under both real and fake Jest timers.\n */\nfunction universalJestAdvanceTimersBy(ms: number) {\n if (jestFakeTimersAreEnabled()) {\n return jest.advanceTimersByTime(ms);\n } else {\n return Promise.resolve();\n }\n}\n\nconst defaultOptions: Required<UserEventSetupOptions> = {\n delay: 0,\n advanceTimers: universalJestAdvanceTimersBy,\n};\n\n/**\n * Creates a new instance of user event instance with the given options.\n *\n * @param options\n * @returns UserEvent instance\n */\nexport function setup(options?: UserEventSetupOptions) {\n const config = createConfig(options);\n const instance = createInstance(config);\n return instance;\n}\n\n/**\n * Options affecting all user event interactions.\n *\n * @param delay between some subsequent inputs like typing a series of characters\n * @param advanceTimers function to be called to advance fake timers\n */\nexport interface UserEventConfig {\n delay: number;\n advanceTimers: (delay: number) => Promise<void> | void;\n}\n\nfunction createConfig(options?: UserEventSetupOptions): UserEventConfig {\n return {\n ...defaultOptions,\n ...options,\n };\n}\n\n/**\n * UserEvent instance used to invoke user interaction functions.\n */\nexport interface UserEventInstance {\n config: UserEventConfig;\n\n press: (element: HostElement) => Promise<void>;\n longPress: (element: HostElement, options?: PressOptions) => Promise<void>;\n\n /**\n * Simulate user pressing on a given `TextInput` element and typing given text.\n *\n * This method will trigger the events for each character of the text:\n * `keyPress`, `change`, `changeText`, `endEditing`, etc.\n *\n * It will also trigger events connected with entering and leaving the text\n * input.\n *\n * The exact events sent depend on the props of the TextInput (`editable`,\n * `multiline`, etc) and passed options.\n *\n * @param element TextInput element to type on\n * @param text Text to type\n * @param options Options affecting typing behavior:\n * - `skipPress` - if true, `pressIn` and `pressOut` events will not be\n * triggered.\n * - `submitEditing` - if true, `submitEditing` event will be triggered after\n * typing the text.\n */\n type: (element: HostElement, text: string, options?: TypeOptions) => Promise<void>;\n\n /**\n * Simulate user clearing the text of a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. pressing backspace to delete all text\n * 4. leaving TextInput\n *\n * @param element TextInput element to clear\n */\n clear: (element: HostElement) => Promise<void>;\n\n /**\n * Simulate user pasting the text to a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. paste the text\n * 4. leaving TextInput\n *\n * @param element TextInput element to paste to\n */\n paste: (element: HostElement, text: string) => Promise<void>;\n\n /**\n * Simlate user scorlling a ScrollView element.\n *\n * @param element ScrollView element\n * @returns\n */\n scrollTo: (element: HostElement, options: ScrollToOptions) => Promise<void>;\n}\n\nfunction createInstance(config: UserEventConfig): UserEventInstance {\n const instance = {\n config,\n } as UserEventInstance;\n\n // Bind interactions to given User Event instance.\n const api = {\n press: wrapAndBindImpl(instance, press),\n longPress: wrapAndBindImpl(instance, longPress),\n type: wrapAndBindImpl(instance, type),\n clear: wrapAndBindImpl(instance, clear),\n paste: wrapAndBindImpl(instance, paste),\n scrollTo: wrapAndBindImpl(instance, scrollTo),\n };\n\n Object.assign(instance, api);\n return instance;\n}\n\n/**\n * Wraps user interaction with `wrapAsync` (temporarily disable `act` environment while\n * calling & resolving the async callback, then flush the microtask queue)\n *\n * This implementation is sourced from `testing-library/user-event`\n * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121\n */\nfunction wrapAndBindImpl<\n Args extends never[],\n Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,\n>(instance: UserEventInstance, impl: Impl) {\n function method(...args: Args) {\n return wrapAsync(() =>\n // eslint-disable-next-line promise/prefer-await-to-then\n impl.apply(instance, args).then(async (result) => {\n await wait(instance.config);\n return result;\n }),\n );\n }\n\n // Copy implementation name to the returned function\n Object.defineProperty(method, 'name', { get: () => impl.name });\n\n return method as Impl;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,OAAA,GAAAL,OAAA;AAEA,IAAAM,KAAA,GAAAN,OAAA;AACA,IAAAO,MAAA,GAAAP,OAAA;AAwBA;AACA;AACA;AACA,SAASQ,4BAA4BA,CAACC,EAAU,EAAE;EAChD,IAAI,IAAAC,gCAAwB,EAAC,CAAC,EAAE;IAC9B,OAAOC,IAAI,CAACC,mBAAmB,CAACH,EAAE,CAAC;EACrC,CAAC,MAAM;IACL,OAAOI,OAAO,CAACC,OAAO,CAAC,CAAC;EAC1B;AACF;AAEA,MAAMC,cAA+C,GAAG;EACtDC,KAAK,EAAE,CAAC;EACRC,aAAa,EAAET;AACjB,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACO,SAASU,KAAKA,CAACC,OAA+B,EAAE;EACrD,MAAMC,MAAM,GAAGC,YAAY,CAACF,OAAO,CAAC;EACpC,MAAMG,QAAQ,GAAGC,cAAc,CAACH,MAAM,CAAC;EACvC,OAAOE,QAAQ;AACjB;;AAEA;AACA;AACA;AAC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ignoreList":[]}
1
+ {"version":3,"file":"setup.js","names":["_timers","require","_validateOptions","_wrapAsync","_clear","_paste","_press","_scroll","_type","_utils","universalJestAdvanceTimersBy","ms","jestFakeTimersAreEnabled","jest","advanceTimersByTime","Promise","resolve","defaultOptions","delay","advanceTimers","setup","options","config","createConfig","instance","createInstance","callsite","rest","validateOptions","undefined","api","press","wrapAndBindImpl","longPress","type","clear","paste","scrollTo","Object","assign","impl","method","args","wrapAsync","apply","then","result","wait","defineProperty","get","name"],"sources":["../../../src/user-event/setup/setup.ts"],"sourcesContent":["import type { HostElement } from 'test-renderer';\n\nimport { jestFakeTimersAreEnabled } from '../../helpers/timers';\nimport { validateOptions } from '../../helpers/validate-options';\nimport { wrapAsync } from '../../helpers/wrap-async';\nimport { clear } from '../clear';\nimport { paste } from '../paste';\nimport type { PressOptions } from '../press';\nimport { longPress, press } from '../press';\nimport type { ScrollToOptions } from '../scroll';\nimport { scrollTo } from '../scroll';\nimport type { TypeOptions } from '../type';\nimport { type } from '../type';\nimport { wait } from '../utils';\n\nexport interface UserEventSetupOptions {\n /**\n * Between some subsequent inputs like typing a series of characters\n * the code execution is delayed per `setTimeout` for (at least) `delay` seconds.\n * This moves the next changes at least to next macro task\n * and allows other (asynchronous) code to run between events.\n *\n * `null` prevents `setTimeout` from being called.\n *\n * @default 0\n */\n delay?: number;\n\n /**\n * Function to be called to advance fake timers. Setting it is necessary for\n * fake timers to work.\n *\n * @example jest.advanceTimersByTime\n */\n advanceTimers?: (delay: number) => Promise<void> | void;\n}\n\n/**\n * This functions allow wait to work correctly under both real and fake Jest timers.\n */\nfunction universalJestAdvanceTimersBy(ms: number) {\n if (jestFakeTimersAreEnabled()) {\n return jest.advanceTimersByTime(ms);\n } else {\n return Promise.resolve();\n }\n}\n\nconst defaultOptions: Required<UserEventSetupOptions> = {\n delay: 0,\n advanceTimers: universalJestAdvanceTimersBy,\n};\n\n/**\n * Creates a new instance of user event instance with the given options.\n *\n * @param options\n * @returns UserEvent instance\n */\nexport function setup(options?: UserEventSetupOptions) {\n const config = createConfig(options, setup);\n const instance = createInstance(config);\n return instance;\n}\n\n/**\n * Options affecting all user event interactions.\n *\n * @param delay between some subsequent inputs like typing a series of characters\n * @param advanceTimers function to be called to advance fake timers\n */\nexport interface UserEventConfig {\n delay: number;\n advanceTimers: (delay: number) => Promise<void> | void;\n}\n\nfunction createConfig(\n options: UserEventSetupOptions = {},\n // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\n callsite: Function,\n): UserEventConfig {\n const { delay, advanceTimers, ...rest } = options;\n validateOptions('userEvent.setup', rest, callsite);\n\n return {\n ...defaultOptions,\n ...(delay !== undefined && { delay }),\n ...(advanceTimers !== undefined && { advanceTimers }),\n };\n}\n\n/**\n * UserEvent instance used to invoke user interaction functions.\n */\nexport interface UserEventInstance {\n config: UserEventConfig;\n\n press: (element: HostElement) => Promise<void>;\n longPress: (element: HostElement, options?: PressOptions) => Promise<void>;\n\n /**\n * Simulate user pressing on a given `TextInput` element and typing given text.\n *\n * This method will trigger the events for each character of the text:\n * `keyPress`, `change`, `changeText`, `endEditing`, etc.\n *\n * It will also trigger events connected with entering and leaving the text\n * input.\n *\n * The exact events sent depend on the props of the TextInput (`editable`,\n * `multiline`, etc) and passed options.\n *\n * @param element TextInput element to type on\n * @param text Text to type\n * @param options Options affecting typing behavior:\n * - `skipPress` - if true, `pressIn` and `pressOut` events will not be\n * triggered.\n * - `submitEditing` - if true, `submitEditing` event will be triggered after\n * typing the text.\n */\n type: (element: HostElement, text: string, options?: TypeOptions) => Promise<void>;\n\n /**\n * Simulate user clearing the text of a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. pressing backspace to delete all text\n * 4. leaving TextInput\n *\n * @param element TextInput element to clear\n */\n clear: (element: HostElement) => Promise<void>;\n\n /**\n * Simulate user pasting the text to a given `TextInput` element.\n *\n * This method will simulate:\n * 1. entering TextInput\n * 2. selecting all text\n * 3. paste the text\n * 4. leaving TextInput\n *\n * @param element TextInput element to paste to\n */\n paste: (element: HostElement, text: string) => Promise<void>;\n\n /**\n * Simlate user scorlling a ScrollView element.\n *\n * @param element ScrollView element\n * @returns\n */\n scrollTo: (element: HostElement, options: ScrollToOptions) => Promise<void>;\n}\n\nfunction createInstance(config: UserEventConfig): UserEventInstance {\n const instance = {\n config,\n } as UserEventInstance;\n\n // Bind interactions to given User Event instance.\n const api = {\n press: wrapAndBindImpl(instance, press),\n longPress: wrapAndBindImpl(instance, longPress),\n type: wrapAndBindImpl(instance, type),\n clear: wrapAndBindImpl(instance, clear),\n paste: wrapAndBindImpl(instance, paste),\n scrollTo: wrapAndBindImpl(instance, scrollTo),\n };\n\n Object.assign(instance, api);\n return instance;\n}\n\n/**\n * Wraps user interaction with `wrapAsync` (temporarily disable `act` environment while\n * calling & resolving the async callback, then flush the microtask queue)\n *\n * This implementation is sourced from `testing-library/user-event`\n * @see https://github.com/testing-library/user-event/blob/7a305dee9ab833d6f338d567fc2e862b4838b76a/src/setup/setup.ts#L121\n */\nfunction wrapAndBindImpl<\n Args extends never[],\n Impl extends (this: UserEventInstance, ...args: Args) => Promise<unknown>,\n>(instance: UserEventInstance, impl: Impl) {\n function method(...args: Args) {\n return wrapAsync(() =>\n // eslint-disable-next-line promise/prefer-await-to-then\n impl.apply(instance, args).then(async (result) => {\n await wait(instance.config);\n return result;\n }),\n );\n }\n\n // Copy implementation name to the returned function\n Object.defineProperty(method, 'name', { get: () => impl.name });\n\n return method as Impl;\n}\n"],"mappings":";;;;;;AAEA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,MAAA,GAAAL,OAAA;AAEA,IAAAM,OAAA,GAAAN,OAAA;AAEA,IAAAO,KAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAA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EAAEU,UAAI,CAAC;IACrCC,KAAK,EAAEH,eAAe,CAACR,QAAQ,EAAEW,YAAK,CAAC;IACvCC,KAAK,EAAEJ,eAAe,CAACR,QAAQ,EAAEY,YAAK,CAAC;IACvCC,QAAQ,EAAEL,eAAe,CAACR,QAAQ,EAAEa,gBAAQ;EAC9C,CAAC;EAEDC,MAAM,CAACC,MAAM,CAACf,QAAQ,EAAEM,GAAG,CAAC;EAC5B,OAAON,QAAQ;AACjB;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASQ,eAAeA,CAGtBR,QAA2B,EAAEgB,IAAU,EAAE;EACzC,SAASC,MAAMA,CAAC,GAAGC,IAAU,EAAE;IAC7B,OAAO,IAAAC,oBAAS,EAAC;IACf;IACAH,IAAI,CAACI,KAAK,CAACpB,QAAQ,EAAEkB,IAAI,CAAC,CAACG,IAAI,CAAC,MAAOC,MAAM,IAAK;MAChD,MAAM,IAAAC,WAAI,EAACvB,QAAQ,CAACF,MAAM,CAAC;MAC3B,OAAOwB,MAAM;IACf,CAAC,CACH,CAAC;EACH;;EAEA;EACAR,MAAM,CAACU,cAAc,CAACP,MAAM,EAAE,MAAM,EAAE;IAAEQ,GAAG,EAAEA,CAAA,KAAMT,IAAI,CAACU;EAAK,CAAC,CAAC;EAE/D,OAAOT,MAAM;AACf","ignoreList":[]}
package/build/wait-for.js CHANGED
@@ -40,9 +40,7 @@ function waitForInternal(expectation, {
40
40
  while (!finished) {
41
41
  if (!(0, _timers.jestFakeTimersAreEnabled)()) {
42
42
  const error = new Error(`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`);
43
- if (stackTraceError) {
44
- (0, _errors.copyStackTrace)(error, stackTraceError);
45
- }
43
+ (0, _errors.copyStackTraceIfNeeded)(error, stackTraceError);
46
44
  reject(error);
47
45
  return;
48
46
  }
@@ -96,16 +94,17 @@ function waitForInternal(expectation, {
96
94
  function checkRealTimersCallback() {
97
95
  if ((0, _timers.jestFakeTimersAreEnabled)()) {
98
96
  const error = new Error(`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`);
99
- if (stackTraceError) {
100
- (0, _errors.copyStackTrace)(error, stackTraceError);
101
- }
97
+ (0, _errors.copyStackTraceIfNeeded)(error, stackTraceError);
102
98
  return reject(error);
103
99
  } else {
104
100
  return checkExpectation();
105
101
  }
106
102
  }
107
103
  function checkExpectation() {
108
- if (promiseStatus === 'pending') return;
104
+ /* istanbul ignore next */
105
+ if (promiseStatus === 'pending') {
106
+ return;
107
+ }
109
108
  try {
110
109
  const result = expectation();
111
110
 
@@ -146,14 +145,10 @@ function waitForInternal(expectation, {
146
145
  } else {
147
146
  error = new Error(String(lastError));
148
147
  }
149
- if (stackTraceError) {
150
- (0, _errors.copyStackTrace)(error, stackTraceError);
151
- }
148
+ (0, _errors.copyStackTraceIfNeeded)(error, stackTraceError);
152
149
  } else {
153
150
  error = new Error('Timed out in waitFor.');
154
- if (stackTraceError) {
155
- (0, _errors.copyStackTrace)(error, stackTraceError);
156
- }
151
+ (0, _errors.copyStackTraceIfNeeded)(error, stackTraceError);
157
152
  }
158
153
  if (typeof onTimeout === 'function') {
159
154
  const result = onTimeout(error);
@@ -1 +1 @@
1
- {"version":3,"file":"wait-for.js","names":["_act","require","_config","_flushMicroTasks","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","fakeTimersType","getJestFakeTimersType","checkExpectation","fakeTimeRemaining","jestFakeTimersAreEnabled","error","Error","copyStackTrace","handleTimeout","act","jest","advanceTimersByTimeAsync","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 { act } from './act';\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { copyStackTrace, ErrorWithStack } from './helpers/errors';\nimport {\n clearTimeout,\n getJestFakeTimersType,\n jestFakeTimersAreEnabled,\n setTimeout,\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 fakeTimersType = getJestFakeTimersType();\n\n if (fakeTimersType) {\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 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 await act(() =>\n fakeTimersType === 'modern'\n ? jest.advanceTimersByTimeAsync(interval)\n : jest.advanceTimersByTime(interval),\n );\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 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 (!fakeTimersType) {\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-expect-error result can be a promise\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as unknown as Promise<T>;\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 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,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAMA,IAAAK,UAAA,GAAAL,OAAA;AAXA;;AAaA,MAAMM,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,CA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IAAE,GAAGwC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAMjD,eAAe,CAACC,WAAW,EAAE+C,qBAAqB,CAAC,CAAC;AAC7E","ignoreList":[]}
1
+ {"version":3,"file":"wait-for.js","names":["_act","require","_config","_flushMicroTasks","_errors","_timers","_wrapAsync","DEFAULT_INTERVAL","waitForInternal","expectation","timeout","getConfig","asyncUtilTimeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","fakeTimersType","getJestFakeTimersType","checkExpectation","fakeTimeRemaining","jestFakeTimersAreEnabled","error","Error","copyStackTraceIfNeeded","handleTimeout","act","jest","advanceTimersByTimeAsync","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 { act } from './act';\nimport { getConfig } from './config';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { copyStackTraceIfNeeded, ErrorWithStack } from './helpers/errors';\nimport {\n clearTimeout,\n getJestFakeTimersType,\n jestFakeTimersAreEnabled,\n setTimeout,\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 fakeTimersType = getJestFakeTimersType();\n\n if (fakeTimersType) {\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 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 copyStackTraceIfNeeded(error, stackTraceError);\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 await act(() =>\n fakeTimersType === 'modern'\n ? jest.advanceTimersByTimeAsync(interval)\n : jest.advanceTimersByTime(interval),\n );\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 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 (!fakeTimersType) {\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 copyStackTraceIfNeeded(error, stackTraceError);\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n /* istanbul ignore next */\n if (promiseStatus === 'pending') {\n return;\n }\n\n try {\n const result = expectation();\n\n // @ts-expect-error result can be a promise\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as unknown as Promise<T>;\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 copyStackTraceIfNeeded(error, stackTraceError);\n } else {\n error = new Error('Timed out in waitFor.');\n copyStackTraceIfNeeded(error, stackTraceError);\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 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,IAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAMA,IAAAK,UAAA,GAAAL,OAAA;AAXA;;AAaA,MAAMM,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,cAAc,GAAG,IAAAC,6BAAqB,EAAC,CAAC;IAE9C,IAAID,cAAc,EAAE;MAClBE,gBAAgB,CAAC,CAAC;MAClB;MACA;MACA;MACA;MACA,IAAIC,iBAAiB,GAAGlB,OAAO;MAC/B,OAAO,CAACY,QAAQ,EAAE;QAChB,IAAI,CAAC,IAAAO,gCAAwB,EAAC,CAAC,EAAE;UAC/B,MAAMC,KAAK,GAAG,IAAIC,KAAK,CACrB,kUACF,CAAC;UACD,IAAAC,8BAAsB,EAACF,KAAK,EAAEhB,eAAe,CAAC;UAC9CK,MAAM,CAACW,KAAK,CAAC;UACb;QACF;;QAEA;QACA,IAAIF,iBAAiB,IAAI,CAAC,EAAE;UAC1B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,SAAS,CAACe,KAAK,CAAC;QAC/B,IAAIiB,MAAM,EAAE;UACVjB,KAAK,GAAGiB,MAAM;QAChB;MACF;MACAL,MAAM,CAAC;QAAEI,IAAI,EAAE,OAAO;QAAEhB;MAAM,CAAC,CAAC;IAClC;EACF,CAAC,CAAC;AACJ;AAEO,SAASuB,OAAOA,CAAI5C,WAAoB,EAAE6C,OAAwB,EAAc;EACrF;EACA,MAAMxC,eAAe,GAAG,IAAIyC,sBAAc,CAAC,mBAAmB,EAAEF,OAAO,CAAC;EACxE,MAAMG,qBAAqB,GAAG;IAAE1C,eAAe;IAAE,GAAGwC;EAAQ,CAAC;EAE7D,OAAO,IAAAG,oBAAS,EAAC,MAAMjD,eAAe,CAACC,WAAW,EAAE+C,qBAAqB,CAAC,CAAC;AAC7E","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "14.0.0-alpha.6",
3
+ "version": "14.0.0-beta.0",
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",
@@ -39,7 +39,7 @@
39
39
  "build": "yarn clean && yarn build:js && yarn build:ts",
40
40
  "release": "release-it",
41
41
  "release:rc": "release-it --preRelease=rc",
42
- "release:alpha": "release-it --preRelease=alpha"
42
+ "release:beta": "release-it --preRelease=beta"
43
43
  },
44
44
  "files": [
45
45
  "build/",
@@ -59,7 +59,7 @@
59
59
  "jest": ">=29.0.0",
60
60
  "react": ">=19.0.0",
61
61
  "react-native": ">=0.78",
62
- "test-renderer": "~0.10.1"
62
+ "test-renderer": "^0.14.0"
63
63
  },
64
64
  "peerDependenciesMeta": {
65
65
  "jest": {
@@ -91,7 +91,7 @@
91
91
  "react-native": "0.83.1",
92
92
  "react-native-gesture-handler": "^2.29.1",
93
93
  "release-it": "^19.0.6",
94
- "test-renderer": "0.13.0",
94
+ "test-renderer": "0.14.0",
95
95
  "typescript": "^5.9.3",
96
96
  "typescript-eslint": "^8.47.0"
97
97
  },
@@ -1 +0,0 @@
1
- export declare function checkReactVersionAtLeast(major: number, minor: number): boolean;
@@ -1,14 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.checkReactVersionAtLeast = checkReactVersionAtLeast;
7
- var React = _interopRequireWildcard(require("react"));
8
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
9
- function checkReactVersionAtLeast(major, minor) {
10
- if (React.version === undefined) return false;
11
- const [actualMajor, actualMinor] = React.version.split('.').map(Number);
12
- return actualMajor > major || actualMajor === major && actualMinor >= minor;
13
- }
14
- //# sourceMappingURL=react-versions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"react-versions.js","names":["React","_interopRequireWildcard","require","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","checkReactVersionAtLeast","major","minor","version","undefined","actualMajor","actualMinor","split","map","Number"],"sources":["../src/react-versions.ts"],"sourcesContent":["import * as React from 'react';\n\nexport function checkReactVersionAtLeast(major: number, minor: number): boolean {\n if (React.version === undefined) return false;\n const [actualMajor, actualMinor] = React.version.split('.').map(Number);\n\n return actualMajor > major || (actualMajor === major && actualMinor >= minor);\n}\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAA+B,SAAAD,wBAAAE,CAAA,EAAA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