@testing-library/react-native 12.7.2 → 13.0.0-alpha.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.
- package/README.md +2 -7
- package/build/act.d.ts +2 -1
- package/build/act.js +14 -10
- package/build/act.js.map +1 -1
- package/build/config.d.ts +11 -1
- package/build/config.js +2 -1
- package/build/config.js.map +1 -1
- package/build/flush-micro-tasks.d.ts +0 -18
- package/build/flush-micro-tasks.js +0 -25
- package/build/flush-micro-tasks.js.map +1 -1
- package/build/helpers/{debug-deep.d.ts → debug.d.ts} +1 -1
- package/build/helpers/{debug-deep.js → debug.js} +3 -3
- package/build/helpers/debug.js.map +1 -0
- package/build/helpers/host-component-names.js +1 -1
- package/build/helpers/host-component-names.js.map +1 -1
- package/build/helpers/wrap-async.js +10 -27
- package/build/helpers/wrap-async.js.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.flow.js +4 -37
- package/build/index.js +2 -1
- package/build/index.js.map +1 -1
- package/build/render-hook.js +1 -1
- package/build/render-hook.js.map +1 -1
- package/build/render.d.ts +11 -53
- package/build/render.js +12 -8
- package/build/render.js.map +1 -1
- package/build/screen.js +0 -25
- package/build/screen.js.map +1 -1
- package/build/tsconfig.release.tsbuildinfo +1 -0
- package/build/within.d.ts +4 -28
- package/build/within.js +0 -4
- package/build/within.js.map +1 -1
- package/matchers.d.ts +1 -0
- package/matchers.js +2 -0
- package/package.json +29 -24
- package/typings/index.flow.js +4 -37
- package/build/helpers/debug-deep.js.map +0 -1
- package/build/helpers/debug-shallow.d.ts +0 -6
- package/build/helpers/debug-shallow.js +0 -25
- package/build/helpers/debug-shallow.js.map +0 -1
- package/build/queries/accessibility-state.d.ts +0 -19
- package/build/queries/accessibility-state.js +0 -59
- package/build/queries/accessibility-state.js.map +0 -1
- package/build/queries/accessibility-value.d.ts +0 -19
- package/build/queries/accessibility-value.js +0 -59
- package/build/queries/accessibility-value.js.map +0 -1
- package/build/shallow.d.ts +0 -8
- package/build/shallow.js +0 -24
- package/build/shallow.js.map +0 -1
- package/extend-expect.d.ts +0 -1
- package/extend-expect.js +0 -1
package/README.md
CHANGED
|
@@ -44,16 +44,12 @@ This library has a `peerDependencies` listing for `react-test-renderer`. Make su
|
|
|
44
44
|
|
|
45
45
|
### Additional Jest matchers
|
|
46
46
|
|
|
47
|
-
You can use the built-in Jest matchers by
|
|
48
|
-
|
|
49
|
-
```ts
|
|
50
|
-
import '@testing-library/react-native/extend-expect';
|
|
51
|
-
```
|
|
47
|
+
You can use the built-in Jest matchers automatically by having any import from `@testing-library/react-native` in your test.
|
|
52
48
|
|
|
53
49
|
## Example
|
|
54
50
|
|
|
55
51
|
```jsx
|
|
56
|
-
import { render, screen,
|
|
52
|
+
import { render, screen, userEvent } from '@testing-library/react-native';
|
|
57
53
|
import { QuestionsBoard } from '../QuestionsBoard';
|
|
58
54
|
|
|
59
55
|
// It is recommended to use userEvent with fake timers
|
|
@@ -109,7 +105,6 @@ React Native Testing Library consists of following APIs:
|
|
|
109
105
|
- [Migration to 12.0](https://callstack.github.io/react-native-testing-library/docs/migration/v12)
|
|
110
106
|
- [Migration to built-in Jest Matchers](https://callstack.github.io/react-native-testing-library/docs/migration/jest-matchers)
|
|
111
107
|
|
|
112
|
-
|
|
113
108
|
## Troubleshooting
|
|
114
109
|
|
|
115
110
|
- [Troubleshooting guide](https://callstack.github.io/react-native-testing-library/docs/guides/troubleshooting)
|
package/build/act.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
1
2
|
import { act as reactTestRendererAct } from 'react-test-renderer';
|
|
2
|
-
type ReactAct = typeof reactTestRendererAct;
|
|
3
|
+
type ReactAct = 0 extends 1 & typeof React.act ? typeof reactTestRendererAct : typeof React.act;
|
|
3
4
|
declare global {
|
|
4
5
|
var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;
|
|
5
6
|
}
|
package/build/act.js
CHANGED
|
@@ -6,10 +6,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
exports.getIsReactActEnvironment = getIsReactActEnvironment;
|
|
8
8
|
exports.setReactActEnvironment = setIsReactActEnvironment;
|
|
9
|
+
var React = _interopRequireWildcard(require("react"));
|
|
9
10
|
var _reactTestRenderer = require("react-test-renderer");
|
|
10
|
-
|
|
11
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
11
13
|
// This file and the act() implementation is sourced from react-testing-library
|
|
12
|
-
// https://github.com/testing-library/react-testing-library/blob/
|
|
14
|
+
// https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/types/index.d.ts
|
|
15
|
+
|
|
16
|
+
const reactAct = typeof React.act === 'function' ? React.act : _reactTestRenderer.act;
|
|
13
17
|
|
|
14
18
|
// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT
|
|
15
19
|
|
|
@@ -23,17 +27,13 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
23
27
|
return callback => {
|
|
24
28
|
const previousActEnvironment = getIsReactActEnvironment();
|
|
25
29
|
setIsReactActEnvironment(true);
|
|
26
|
-
|
|
27
|
-
// this code is riddled with eslint disabling comments because this doesn't use real promises but eslint thinks we do
|
|
28
30
|
try {
|
|
29
31
|
// The return value of `act` is always a thenable.
|
|
30
32
|
let callbackNeedsToBeAwaited = false;
|
|
31
33
|
const actResult = actImplementation(() => {
|
|
32
34
|
const result = callback();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// eslint-disable-next-line promise/prefer-await-to-then
|
|
36
|
-
typeof result.then === 'function') {
|
|
35
|
+
// @ts-expect-error TS is too strict here
|
|
36
|
+
if (result !== null && typeof result === 'object' && typeof result.then === 'function') {
|
|
37
37
|
callbackNeedsToBeAwaited = true;
|
|
38
38
|
}
|
|
39
39
|
return result;
|
|
@@ -42,14 +42,16 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
42
42
|
const thenable = actResult;
|
|
43
43
|
return {
|
|
44
44
|
then: (resolve, reject) => {
|
|
45
|
-
// eslint-disable-next-line
|
|
45
|
+
// eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then
|
|
46
46
|
thenable.then(
|
|
47
47
|
// eslint-disable-next-line promise/always-return
|
|
48
48
|
returnValue => {
|
|
49
49
|
setIsReactActEnvironment(previousActEnvironment);
|
|
50
|
+
// @ts-expect-error
|
|
50
51
|
resolve(returnValue);
|
|
51
52
|
}, error => {
|
|
52
53
|
setIsReactActEnvironment(previousActEnvironment);
|
|
54
|
+
// @ts-expect-error
|
|
53
55
|
reject(error);
|
|
54
56
|
});
|
|
55
57
|
}
|
|
@@ -66,6 +68,8 @@ function withGlobalActEnvironment(actImplementation) {
|
|
|
66
68
|
}
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
|
|
72
|
+
// @ts-expect-error
|
|
73
|
+
const act = withGlobalActEnvironment(reactAct);
|
|
70
74
|
var _default = exports.default = act;
|
|
71
75
|
//# sourceMappingURL=act.js.map
|
package/build/act.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"act.js","names":["
|
|
1
|
+
{"version":3,"file":"act.js","names":["React","_interopRequireWildcard","require","_reactTestRenderer","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","reactAct","act","reactTestRendererAct","setIsReactActEnvironment","isReactActEnvironment","globalThis","IS_REACT_ACT_ENVIRONMENT","getIsReactActEnvironment","withGlobalActEnvironment","actImplementation","callback","previousActEnvironment","callbackNeedsToBeAwaited","actResult","result","then","thenable","resolve","reject","returnValue","error","_default","exports"],"sources":["../src/act.ts"],"sourcesContent":["// This file and the act() implementation is sourced from react-testing-library\n// https://github.com/testing-library/react-testing-library/blob/3dcd8a9649e25054c0e650d95fca2317b7008576/types/index.d.ts\nimport * as React from 'react';\nimport { act as reactTestRendererAct } from 'react-test-renderer';\n\nconst reactAct = typeof React.act === 'function' ? React.act : reactTestRendererAct;\ntype ReactAct = 0 extends 1 & typeof React.act ? typeof reactTestRendererAct : typeof React.act;\n\n// See https://github.com/reactwg/react-18/discussions/102 for more context on global.IS_REACT_ACT_ENVIRONMENT\ndeclare global {\n var IS_REACT_ACT_ENVIRONMENT: boolean | undefined;\n}\n\nfunction setIsReactActEnvironment(isReactActEnvironment: boolean | undefined) {\n globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;\n}\n\nfunction getIsReactActEnvironment() {\n return globalThis.IS_REACT_ACT_ENVIRONMENT;\n}\n\nfunction withGlobalActEnvironment(actImplementation: ReactAct) {\n return (callback: Parameters<ReactAct>[0]) => {\n const previousActEnvironment = getIsReactActEnvironment();\n setIsReactActEnvironment(true);\n\n try {\n // The return value of `act` is always a thenable.\n let callbackNeedsToBeAwaited = false;\n const actResult = actImplementation(() => {\n const result = callback();\n // @ts-expect-error TS is too strict here\n if (result !== null && typeof result === 'object' && typeof result.then === 'function') {\n callbackNeedsToBeAwaited = true;\n }\n return result;\n });\n\n if (callbackNeedsToBeAwaited) {\n const thenable = actResult;\n return {\n then: (resolve: (value: never) => never, reject: (value: never) => never) => {\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n thenable.then(\n // eslint-disable-next-line promise/always-return\n (returnValue) => {\n setIsReactActEnvironment(previousActEnvironment);\n // @ts-expect-error\n resolve(returnValue);\n },\n (error) => {\n setIsReactActEnvironment(previousActEnvironment);\n // @ts-expect-error\n reject(error);\n },\n );\n },\n };\n } else {\n setIsReactActEnvironment(previousActEnvironment);\n return actResult;\n }\n } catch (error) {\n // Can't be a `finally {}` block since we don't know if we have to immediately restore IS_REACT_ACT_ENVIRONMENT\n // or if we have to await the callback first.\n setIsReactActEnvironment(previousActEnvironment);\n throw error;\n }\n };\n}\n\n// @ts-expect-error\nconst act = withGlobalActEnvironment(reactAct) as ReactAct;\n\nexport default act;\nexport { setIsReactActEnvironment as setReactActEnvironment, getIsReactActEnvironment };\n"],"mappings":";;;;;;;;AAEA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,kBAAA,GAAAD,OAAA;AAAkE,SAAAE,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAJ,wBAAAI,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAA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Q,GAAGH,SAAS;QAC1B,OAAO;UACLE,IAAI,EAAEA,CAACE,OAAgC,EAAEC,MAA+B,KAAK;YAC3E;YACAF,QAAQ,CAACD,IAAI;YACX;YACCI,WAAW,IAAK;cACfhB,wBAAwB,CAACQ,sBAAsB,CAAC;cAChD;cACAM,OAAO,CAACE,WAAW,CAAC;YACtB,CAAC,EACAC,KAAK,IAAK;cACTjB,wBAAwB,CAACQ,sBAAsB,CAAC;cAChD;cACAO,MAAM,CAACE,KAAK,CAAC;YACf,CACF,CAAC;UACH;QACF,CAAC;MACH,CAAC,MAAM;QACLjB,wBAAwB,CAACQ,sBAAsB,CAAC;QAChD,OAAOE,SAAS;MAClB;IACF,CAAC,CAAC,OAAOO,KAAK,EAAE;MACd;MACA;MACAjB,wBAAwB,CAACQ,sBAAsB,CAAC;MAChD,MAAMS,KAAK;IACb;EACF,CAAC;AACH;;AAEA;AACA,MAAMnB,GAAG,GAAGO,wBAAwB,CAACR,QAAQ,CAAa;AAAC,IAAAqB,QAAA,GAAAC,OAAA,CAAApC,OAAA,GAE5Ce,GAAG","ignoreList":[]}
|
package/build/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DebugOptions } from './helpers/debug
|
|
1
|
+
import { DebugOptions } from './helpers/debug';
|
|
2
2
|
/**
|
|
3
3
|
* Global configuration options for React Native Testing Library.
|
|
4
4
|
*/
|
|
@@ -9,6 +9,11 @@ export type Config = {
|
|
|
9
9
|
defaultIncludeHiddenElements: boolean;
|
|
10
10
|
/** Default options for `debug` helper. */
|
|
11
11
|
defaultDebugOptions?: Partial<DebugOptions>;
|
|
12
|
+
/**
|
|
13
|
+
* Set to `false` to disable concurrent rendering.
|
|
14
|
+
* Otherwise `render` will default to concurrent rendering.
|
|
15
|
+
*/
|
|
16
|
+
concurrentRoot: boolean;
|
|
12
17
|
};
|
|
13
18
|
export type ConfigAliasOptions = {
|
|
14
19
|
/** RTL-compatibility alias to `defaultIncludeHiddenElements` */
|
|
@@ -39,6 +44,11 @@ export declare function getConfig(): {
|
|
|
39
44
|
defaultIncludeHiddenElements: boolean;
|
|
40
45
|
/** Default options for `debug` helper. */
|
|
41
46
|
defaultDebugOptions?: Partial<DebugOptions>;
|
|
47
|
+
/**
|
|
48
|
+
* Set to `false` to disable concurrent rendering.
|
|
49
|
+
* Otherwise `render` will default to concurrent rendering.
|
|
50
|
+
*/
|
|
51
|
+
concurrentRoot: boolean;
|
|
42
52
|
/** Names for key React Native host components. */
|
|
43
53
|
hostComponentNames?: HostComponentNames;
|
|
44
54
|
};
|
package/build/config.js
CHANGED
package/build/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { DebugOptions } from './helpers/debug
|
|
1
|
+
{"version":3,"file":"config.js","names":["defaultConfig","asyncUtilTimeout","defaultIncludeHiddenElements","concurrentRoot","config","configure","options","defaultHidden","restOptions","configureInternal","option","resetToDefaults","getConfig"],"sources":["../src/config.ts"],"sourcesContent":["import { 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 /**\n * Set to `false` to disable concurrent rendering.\n * Otherwise `render` will default to concurrent rendering.\n */\n concurrentRoot: boolean;\n};\n\nexport type ConfigAliasOptions = {\n /** RTL-compatibility alias to `defaultIncludeHiddenElements` */\n defaultHidden: boolean;\n};\n\nexport type HostComponentNames = {\n text: string;\n textInput: string;\n image: string;\n switch: string;\n scrollView: string;\n modal: string;\n};\n\nexport type InternalConfig = Config & {\n /** Names for key React Native host components. */\n hostComponentNames?: HostComponentNames;\n};\n\nconst defaultConfig: InternalConfig = {\n asyncUtilTimeout: 1000,\n defaultIncludeHiddenElements: false,\n concurrentRoot: true,\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 configureInternal(option: Partial<InternalConfig>) {\n config = {\n ...config,\n ...option,\n };\n}\n\nexport function resetToDefaults() {\n config = { ...defaultConfig };\n}\n\nexport function getConfig() {\n return config;\n}\n"],"mappings":";;;;;;;;;AAEA;AACA;AACA;;AAsCA,MAAMA,aAA6B,GAAG;EACpCC,gBAAgB,EAAE,IAAI;EACtBC,4BAA4B,EAAE,KAAK;EACnCC,cAAc,EAAE;AAClB,CAAC;AAED,IAAIC,MAAM,GAAG;EAAE,GAAGJ;AAAc,CAAC;;AAEjC;AACA;AACA;AACO,SAASK,SAASA,CAACC,OAA6C,EAAE;EACvE,MAAM;IAAEC,aAAa;IAAE,GAAGC;EAAY,CAAC,GAAGF,OAAO;EAEjD,MAAMJ,4BAA4B,GAChCM,WAAW,CAACN,4BAA4B,IACxCK,aAAa,IACbH,MAAM,CAACF,4BAA4B;EAErCE,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGI,WAAW;IACdN;EACF,CAAC;AACH;AAEO,SAASO,iBAAiBA,CAACC,MAA+B,EAAE;EACjEN,MAAM,GAAG;IACP,GAAGA,MAAM;IACT,GAAGM;EACL,CAAC;AACH;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChCP,MAAM,GAAG;IAAE,GAAGJ;EAAc,CAAC;AAC/B;AAEO,SAASY,SAASA,CAAA,EAAG;EAC1B,OAAOR,MAAM;AACf","ignoreList":[]}
|
|
@@ -1,19 +1 @@
|
|
|
1
1
|
export declare function flushMicroTasks(): Promise<unknown>;
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated To be removed in the next major release.
|
|
4
|
-
*/
|
|
5
|
-
type Thenable<T> = {
|
|
6
|
-
then: (callback: () => T) => unknown;
|
|
7
|
-
};
|
|
8
|
-
/**
|
|
9
|
-
* This legacy implementation of `flushMicroTasks` is used for compatibility with
|
|
10
|
-
* older versions of React Native (pre 0.71) which uses Promise polyfil.
|
|
11
|
-
*
|
|
12
|
-
* For users with older version of React Native there is a workaround of using our own
|
|
13
|
-
* Jest preset instead the `react-native` one, but requiring such change would be a
|
|
14
|
-
* breaking change for existing users.
|
|
15
|
-
*
|
|
16
|
-
* @deprecated To be removed in the next major release.
|
|
17
|
-
*/
|
|
18
|
-
export declare function flushMicroTasksLegacy(): Thenable<void>;
|
|
19
|
-
export {};
|
|
@@ -4,33 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.flushMicroTasks = flushMicroTasks;
|
|
7
|
-
exports.flushMicroTasksLegacy = flushMicroTasksLegacy;
|
|
8
7
|
var _timers = require("./helpers/timers");
|
|
9
8
|
function flushMicroTasks() {
|
|
10
9
|
return new Promise(resolve => (0, _timers.setImmediate)(resolve));
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @deprecated To be removed in the next major release.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* This legacy implementation of `flushMicroTasks` is used for compatibility with
|
|
19
|
-
* older versions of React Native (pre 0.71) which uses Promise polyfil.
|
|
20
|
-
*
|
|
21
|
-
* For users with older version of React Native there is a workaround of using our own
|
|
22
|
-
* Jest preset instead the `react-native` one, but requiring such change would be a
|
|
23
|
-
* breaking change for existing users.
|
|
24
|
-
*
|
|
25
|
-
* @deprecated To be removed in the next major release.
|
|
26
|
-
*/
|
|
27
|
-
function flushMicroTasksLegacy() {
|
|
28
|
-
return {
|
|
29
|
-
// using "thenable" instead of a Promise, because otherwise it breaks when
|
|
30
|
-
// using "modern" fake timers
|
|
31
|
-
then(resolve) {
|
|
32
|
-
(0, _timers.setImmediate)(resolve);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
11
|
//# sourceMappingURL=flush-micro-tasks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flush-micro-tasks.js","names":["_timers","require","flushMicroTasks","Promise","resolve","setImmediate"
|
|
1
|
+
{"version":3,"file":"flush-micro-tasks.js","names":["_timers","require","flushMicroTasks","Promise","resolve","setImmediate"],"sources":["../src/flush-micro-tasks.ts"],"sourcesContent":["import { setImmediate } from './helpers/timers';\n\nexport function flushMicroTasks() {\n return new Promise((resolve) => setImmediate(resolve));\n}\n"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEO,SAASC,eAAeA,CAAA,EAAG;EAChC,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK,IAAAC,oBAAY,EAACD,OAAO,CAAC,CAAC;AACxD","ignoreList":[]}
|
|
@@ -6,4 +6,4 @@ export type DebugOptions = {
|
|
|
6
6
|
/**
|
|
7
7
|
* Log pretty-printed deep test component instance
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export declare function debug(instance: ReactTestRendererJSON | ReactTestRendererJSON[], options?: DebugOptions | string): void;
|
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.debug = debug;
|
|
7
7
|
var _format = _interopRequireDefault(require("./format"));
|
|
8
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
9
|
/**
|
|
10
10
|
* Log pretty-printed deep test component instance
|
|
11
11
|
*/
|
|
12
|
-
function
|
|
12
|
+
function debug(instance, options) {
|
|
13
13
|
const message = typeof options === 'string' ? options : options?.message;
|
|
14
14
|
const formatOptions = typeof options === 'object' ? {
|
|
15
15
|
mapProps: options?.mapProps
|
|
@@ -22,4 +22,4 @@ function debugDeep(instance, options) {
|
|
|
22
22
|
console.log((0, _format.default)(instance, formatOptions));
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=debug
|
|
25
|
+
//# sourceMappingURL=debug.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"debug.js","names":["_format","_interopRequireDefault","require","e","__esModule","default","debug","instance","options","message","formatOptions","mapProps","undefined","console","log","format"],"sources":["../../src/helpers/debug.ts"],"sourcesContent":["import type { ReactTestRendererJSON } from 'react-test-renderer';\nimport format, { FormatOptions } from './format';\n\nexport type DebugOptions = {\n message?: string;\n} & FormatOptions;\n\n/**\n * Log pretty-printed deep test component instance\n */\nexport function debug(\n instance: ReactTestRendererJSON | ReactTestRendererJSON[],\n options?: DebugOptions | string,\n) {\n const message = typeof options === 'string' ? options : options?.message;\n\n const formatOptions = typeof options === 'object' ? { mapProps: options?.mapProps } : undefined;\n\n if (message) {\n // eslint-disable-next-line no-console\n console.log(`${message}\\n\\n`, format(instance, formatOptions));\n } else {\n // eslint-disable-next-line no-console\n console.log(format(instance, formatOptions));\n }\n}\n"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAiD,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAMjD;AACA;AACA;AACO,SAASG,KAAKA,CACnBC,QAAyD,EACzDC,OAA+B,EAC/B;EACA,MAAMC,OAAO,GAAG,OAAOD,OAAO,KAAK,QAAQ,GAAGA,OAAO,GAAGA,OAAO,EAAEC,OAAO;EAExE,MAAMC,aAAa,GAAG,OAAOF,OAAO,KAAK,QAAQ,GAAG;IAAEG,QAAQ,EAAEH,OAAO,EAAEG;EAAS,CAAC,GAAGC,SAAS;EAE/F,IAAIH,OAAO,EAAE;IACX;IACAI,OAAO,CAACC,GAAG,CAAC,GAAGL,OAAO,MAAM,EAAE,IAAAM,eAAM,EAACR,QAAQ,EAAEG,aAAa,CAAC,CAAC;EAChE,CAAC,MAAM;IACL;IACAG,OAAO,CAACC,GAAG,CAAC,IAAAC,eAAM,EAACR,QAAQ,EAAEG,aAAa,CAAC,CAAC;EAC9C;AACF","ignoreList":[]}
|
|
@@ -41,7 +41,7 @@ function configureHostComponentNamesIfNeeded() {
|
|
|
41
41
|
}
|
|
42
42
|
function detectHostComponentNames() {
|
|
43
43
|
try {
|
|
44
|
-
const renderer = (0, _renderAct.renderWithAct)(
|
|
44
|
+
const renderer = (0, _renderAct.renderWithAct)(/*#__PURE__*/React.createElement(_reactNative.View, null, /*#__PURE__*/React.createElement(_reactNative.Text, {
|
|
45
45
|
testID: "text"
|
|
46
46
|
}, "Hello"), /*#__PURE__*/React.createElement(_reactNative.TextInput, {
|
|
47
47
|
testID: "textInput"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Image","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","image","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Image, Modal, ScrollView, Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Image testID=\"image\" />\n <Switch testID=\"switch\" />\n <ScrollView testID=\"scrollView\" />\n <Modal testID=\"modal\" />\n </View>,\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n image: getByTestId(renderer.root, 'image').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n scrollView: getByTestId(renderer.root, 'scrollView').type as string,\n modal: getByTestId(renderer.root, 'modal').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error ? error.message : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`,\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID,\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().image;\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().switch;\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport function isHostModal(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().modal;\n}\n"],"mappings":";;;;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAA8C,SAAAI,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAN,wBAAAM,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,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AC;AAC3C;AAEA,SAASE,wBAAwBA,CAAA,EAAuB;EACtD,IAAI;IACF,MAAMI,QAAQ,GAAG,IAAAC,wBAAa,
|
|
1
|
+
{"version":3,"file":"host-component-names.js","names":["React","_interopRequireWildcard","require","_reactNative","_config","_renderAct","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","userConfigErrorMessage","getHostComponentNames","hostComponentNames","getConfig","detectHostComponentNames","configureInternal","configureHostComponentNamesIfNeeded","configHostComponentNames","renderer","renderWithAct","createElement","View","Text","testID","TextInput","Image","Switch","ScrollView","Modal","text","getByTestId","root","type","textInput","image","switch","scrollView","modal","error","errorMessage","message","Error","instance","nodes","findAll","node","props","length","isHostText","element","isHostTextInput","isHostImage","isHostSwitch","isHostScrollView","isHostModal"],"sources":["../../src/helpers/host-component-names.tsx"],"sourcesContent":["import * as React from 'react';\nimport { ReactTestInstance } from 'react-test-renderer';\nimport { Image, Modal, ScrollView, Switch, Text, TextInput, View } from 'react-native';\nimport { configureInternal, getConfig, HostComponentNames } from '../config';\nimport { renderWithAct } from '../render-act';\nimport { HostTestInstance } from './component-tree';\n\nconst userConfigErrorMessage = `There seems to be an issue with your configuration that prevents React Native Testing Library from working correctly.\nPlease check if you are using compatible versions of React Native and React Native Testing Library.`;\n\nexport function getHostComponentNames(): HostComponentNames {\n let hostComponentNames = getConfig().hostComponentNames;\n if (!hostComponentNames) {\n hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n }\n\n return hostComponentNames;\n}\n\nexport function configureHostComponentNamesIfNeeded() {\n const configHostComponentNames = getConfig().hostComponentNames;\n if (configHostComponentNames) {\n return;\n }\n\n const hostComponentNames = detectHostComponentNames();\n configureInternal({ hostComponentNames });\n}\n\nfunction detectHostComponentNames(): HostComponentNames {\n try {\n const renderer = renderWithAct(\n <View>\n <Text testID=\"text\">Hello</Text>\n <TextInput testID=\"textInput\" />\n <Image testID=\"image\" />\n <Switch testID=\"switch\" />\n <ScrollView testID=\"scrollView\" />\n <Modal testID=\"modal\" />\n </View>,\n );\n\n return {\n text: getByTestId(renderer.root, 'text').type as string,\n textInput: getByTestId(renderer.root, 'textInput').type as string,\n image: getByTestId(renderer.root, 'image').type as string,\n switch: getByTestId(renderer.root, 'switch').type as string,\n scrollView: getByTestId(renderer.root, 'scrollView').type as string,\n modal: getByTestId(renderer.root, 'modal').type as string,\n };\n } catch (error) {\n const errorMessage =\n error && typeof error === 'object' && 'message' in error ? error.message : null;\n\n throw new Error(\n `Trying to detect host component names triggered the following error:\\n\\n${errorMessage}\\n\\n${userConfigErrorMessage}`,\n );\n }\n}\n\nfunction getByTestId(instance: ReactTestInstance, testID: string) {\n const nodes = instance.findAll(\n (node) => typeof node.type === 'string' && node.props.testID === testID,\n );\n\n if (nodes.length === 0) {\n throw new Error(`Unable to find an element with testID: ${testID}`);\n }\n\n return nodes[0];\n}\n\n/**\n * Checks if the given element is a host Text element.\n * @param element The element to check.\n */\nexport function isHostText(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().text;\n}\n\n/**\n * Checks if the given element is a host TextInput element.\n * @param element The element to check.\n */\nexport function isHostTextInput(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().textInput;\n}\n\n/**\n * Checks if the given element is a host Image element.\n * @param element The element to check.\n */\nexport function isHostImage(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().image;\n}\n\n/**\n * Checks if the given element is a host Switch element.\n * @param element The element to check.\n */\nexport function isHostSwitch(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().switch;\n}\n\n/**\n * Checks if the given element is a host ScrollView element.\n * @param element The element to check.\n */\nexport function isHostScrollView(element?: ReactTestInstance | null): element is HostTestInstance {\n return element?.type === getHostComponentNames().scrollView;\n}\n\n/**\n * Checks if the given element is a host Modal element.\n * @param element The element to check.\n */\nexport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ACrE;EAEA,OAAOoB,KAAK,CAAC,CAAC,CAAC;AACjB;;AAEA;AACA;AACA;AACA;AACO,SAASK,UAAUA,CAACC,OAAkC,EAA+B;EAC1F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACkB,IAAI;AACvD;;AAEA;AACA;AACA;AACA;AACO,SAASqB,eAAeA,CAACD,OAAkC,EAA+B;EAC/F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACsB,SAAS;AAC5D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACF,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACuB,KAAK;AACxD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,YAAYA,CAACH,OAAkC,EAA+B;EAC5F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACwB,MAAM;AACzD;;AAEA;AACA;AACA;AACA;AACO,SAASkB,gBAAgBA,CAACJ,OAAkC,EAA+B;EAChG,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAACyB,UAAU;AAC7D;;AAEA;AACA;AACA;AACA;AACO,SAASkB,WAAWA,CAACL,OAAkC,EAA+B;EAC3F,OAAOA,OAAO,EAAEjB,IAAI,KAAKrB,qBAAqB,CAAC,CAAC,CAAC0B,KAAK;AACxD","ignoreList":[]}
|
|
@@ -4,11 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.wrapAsync = wrapAsync;
|
|
7
|
-
var _act =
|
|
7
|
+
var _act = require("../act");
|
|
8
8
|
var _flushMicroTasks = require("../flush-micro-tasks");
|
|
9
|
-
var _reactVersions = require("../react-versions");
|
|
10
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
11
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
12
9
|
/* istanbul ignore file */
|
|
13
10
|
|
|
14
11
|
/**
|
|
@@ -18,29 +15,15 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
|
|
|
18
15
|
* @returns Result of the callback
|
|
19
16
|
*/
|
|
20
17
|
async function wrapAsync(callback) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
(0, _act.setReactActEnvironment)(previousActEnvironment);
|
|
31
|
-
}
|
|
18
|
+
const previousActEnvironment = (0, _act.getIsReactActEnvironment)();
|
|
19
|
+
(0, _act.setReactActEnvironment)(false);
|
|
20
|
+
try {
|
|
21
|
+
const result = await callback();
|
|
22
|
+
// Flush the microtask queue before restoring the `act` environment
|
|
23
|
+
await (0, _flushMicroTasks.flushMicroTasks)();
|
|
24
|
+
return result;
|
|
25
|
+
} finally {
|
|
26
|
+
(0, _act.setReactActEnvironment)(previousActEnvironment);
|
|
32
27
|
}
|
|
33
|
-
if (!(0, _reactVersions.checkReactVersionAtLeast)(16, 9)) {
|
|
34
|
-
return callback();
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Wrapping with act for react version 16.9 to 17.x
|
|
38
|
-
let result;
|
|
39
|
-
await (0, _act.default)(async () => {
|
|
40
|
-
result = await callback();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Either we have result or `callback` threw error
|
|
44
|
-
return result;
|
|
45
28
|
}
|
|
46
29
|
//# sourceMappingURL=wrap-async.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wrap-async.js","names":["_act","
|
|
1
|
+
{"version":3,"file":"wrap-async.js","names":["_act","require","_flushMicroTasks","wrapAsync","callback","previousActEnvironment","getIsReactActEnvironment","setReactActEnvironment","result","flushMicroTasks"],"sources":["../../src/helpers/wrap-async.ts"],"sourcesContent":["/* istanbul ignore file */\n\nimport { getIsReactActEnvironment, setReactActEnvironment } from '../act';\nimport { flushMicroTasks } from '../flush-micro-tasks';\n\n/**\n * Run given async callback with temporarily disabled `act` environment and flushes microtasks queue.\n *\n * @param callback Async callback to run\n * @returns Result of the callback\n */\nexport async function wrapAsync<Result>(callback: () => Promise<Result>): Promise<Result> {\n const previousActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(false);\n\n try {\n const result = await callback();\n // Flush the microtask queue before restoring the `act` environment\n await flushMicroTasks();\n return result;\n } finally {\n setReactActEnvironment(previousActEnvironment);\n }\n}\n"],"mappings":";;;;;;AAEA,IAAAA,IAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAHA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACO,eAAeE,SAASA,CAASC,QAA+B,EAAmB;EACxF,MAAMC,sBAAsB,GAAG,IAAAC,6BAAwB,EAAC,CAAC;EACzD,IAAAC,2BAAsB,EAAC,KAAK,CAAC;EAE7B,IAAI;IACF,MAAMC,MAAM,GAAG,MAAMJ,QAAQ,CAAC,CAAC;IAC/B;IACA,MAAM,IAAAK,gCAAe,EAAC,CAAC;IACvB,OAAOD,MAAM;EACf,CAAC,SAAS;IACR,IAAAD,2BAAsB,EAACF,sBAAsB,CAAC;EAChD;AACF","ignoreList":[]}
|
package/build/index.d.ts
CHANGED
package/build/index.flow.js
CHANGED
|
@@ -55,10 +55,10 @@ declare type A11yRole =
|
|
|
55
55
|
|
|
56
56
|
declare type A11yState = {|
|
|
57
57
|
disabled?: boolean,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
selected ?: boolean,
|
|
59
|
+
checked ?: boolean | 'mixed',
|
|
60
|
+
busy ?: boolean,
|
|
61
|
+
expanded ?: boolean,
|
|
62
62
|
|};
|
|
63
63
|
|
|
64
64
|
declare type A11yValue = {
|
|
@@ -258,38 +258,6 @@ interface A11yAPI {
|
|
|
258
258
|
queryOptions?: ByRoleOptions,
|
|
259
259
|
waitForOptions?: WaitForOptions
|
|
260
260
|
) => FindAllReturn;
|
|
261
|
-
|
|
262
|
-
// State
|
|
263
|
-
getByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetReturn;
|
|
264
|
-
getAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => GetAllReturn;
|
|
265
|
-
queryByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryReturn;
|
|
266
|
-
queryAllByA11yState: (matcher: A11yState, options?: CommonQueryOptions) => QueryAllReturn;
|
|
267
|
-
findByA11yState: (
|
|
268
|
-
matcher: A11yState,
|
|
269
|
-
queryOptions?: CommonQueryOptions,
|
|
270
|
-
waitForOptions?: WaitForOptions
|
|
271
|
-
) => FindReturn;
|
|
272
|
-
findAllByA11yState: (
|
|
273
|
-
matcher: A11yState,
|
|
274
|
-
queryOptions?: CommonQueryOptions,
|
|
275
|
-
waitForOptions?: WaitForOptions
|
|
276
|
-
) => FindAllReturn;
|
|
277
|
-
|
|
278
|
-
// Value
|
|
279
|
-
getByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetReturn;
|
|
280
|
-
getAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => GetAllReturn;
|
|
281
|
-
queryByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryReturn;
|
|
282
|
-
queryAllByA11yValue: (matcher: A11yValue, options?: CommonQueryOptions) => QueryAllReturn;
|
|
283
|
-
findByA11yValue: (
|
|
284
|
-
matcher: A11yValue,
|
|
285
|
-
queryOptions?: CommonQueryOptions,
|
|
286
|
-
waitForOptions?: WaitForOptions
|
|
287
|
-
) => FindReturn;
|
|
288
|
-
findAllByA11yValue: (
|
|
289
|
-
matcher: A11yValue,
|
|
290
|
-
queryOptions?: CommonQueryOptions,
|
|
291
|
-
waitForOptions?: WaitForOptions
|
|
292
|
-
) => FindAllReturn;
|
|
293
261
|
}
|
|
294
262
|
|
|
295
263
|
interface Thenable {
|
|
@@ -308,7 +276,6 @@ type DebugOptions = {
|
|
|
308
276
|
|
|
309
277
|
type Debug = {
|
|
310
278
|
(options?: DebugOptions | string): void,
|
|
311
|
-
shallow: (message?: string) => void,
|
|
312
279
|
};
|
|
313
280
|
|
|
314
281
|
type Queries = ByTextQueries &
|
package/build/index.js
CHANGED
|
@@ -16,6 +16,7 @@ Object.keys(_pure).forEach(function (key) {
|
|
|
16
16
|
});
|
|
17
17
|
var _flushMicroTasks = require("./flush-micro-tasks");
|
|
18
18
|
var _act = require("./act");
|
|
19
|
+
require("./matchers/extend-expect");
|
|
19
20
|
if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
20
21
|
// If we're running in a test runner that supports afterEach
|
|
21
22
|
// then we'll automatically run cleanup afterEach test
|
|
@@ -25,7 +26,7 @@ if (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {
|
|
|
25
26
|
if (typeof afterEach === 'function') {
|
|
26
27
|
// eslint-disable-next-line no-undef
|
|
27
28
|
afterEach(async () => {
|
|
28
|
-
await (0, _flushMicroTasks.
|
|
29
|
+
await (0, _flushMicroTasks.flushMicroTasks)();
|
|
29
30
|
(0, _pure.cleanup)();
|
|
30
31
|
});
|
|
31
32
|
}
|
package/build/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","
|
|
1
|
+
{"version":3,"file":"index.js","names":["_pure","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_flushMicroTasks","_act","process","env","RNTL_SKIP_AUTO_CLEANUP","afterEach","flushMicroTasks","cleanup","beforeAll","afterAll","previousIsReactActEnvironment","getIsReactActEnvironment","setReactActEnvironment"],"sources":["../src/index.ts"],"sourcesContent":["import { cleanup } from './pure';\nimport { flushMicroTasks } from './flush-micro-tasks';\nimport { getIsReactActEnvironment, setReactActEnvironment } from './act';\nimport './matchers/extend-expect';\n\nif (!process?.env?.RNTL_SKIP_AUTO_CLEANUP) {\n // If we're running in a test runner that supports afterEach\n // then we'll automatically run cleanup afterEach test\n // this ensures that tests run in isolation from each other\n // if you don't like this then either import the `pure` module\n // or set the RNTL_SKIP_AUTO_CLEANUP env variable to 'true'.\n if (typeof afterEach === 'function') {\n // eslint-disable-next-line no-undef\n afterEach(async () => {\n await flushMicroTasks();\n cleanup();\n });\n }\n\n if (typeof beforeAll === 'function' && typeof afterAll === 'function') {\n // This matches the behavior of React < 18.\n let previousIsReactActEnvironment = getIsReactActEnvironment();\n beforeAll(() => {\n previousIsReactActEnvironment = getIsReactActEnvironment();\n setReactActEnvironment(true);\n });\n\n afterAll(() => {\n setReactActEnvironment(previousIsReactActEnvironment);\n });\n }\n}\n\nexport * from './pure';\n"],"mappings":";;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAiCAC,MAAA,CAAAC,IAAA,CAAAH,KAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,KAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,KAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AAhCA,IAAAK,gBAAA,GAAAT,OAAA;AACA,IAAAU,IAAA,GAAAV,OAAA;AACAA,OAAA;AAEA,IAAI,CAACW,OAAO,EAAEC,GAAG,EAAEC,sBAAsB,EAAE;EACzC;EACA;EACA;EACA;EACA;EACA,IAAI,OAAOC,SAAS,KAAK,UAAU,EAAE;IACnC;IACAA,SAAS,CAAC,YAAY;MACpB,MAAM,IAAAC,gCAAe,EAAC,CAAC;MACvB,IAAAC,aAAO,EAAC,CAAC;IACX,CAAC,CAAC;EACJ;EAEA,IAAI,OAAOC,SAAS,KAAK,UAAU,IAAI,OAAOC,QAAQ,KAAK,UAAU,EAAE;IACrE;IACA,IAAIC,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;IAC9DH,SAAS,CAAC,MAAM;MACdE,6BAA6B,GAAG,IAAAC,6BAAwB,EAAC,CAAC;MAC1D,IAAAC,2BAAsB,EAAC,IAAI,CAAC;IAC9B,CAAC,CAAC;IAEFH,QAAQ,CAAC,MAAM;MACb,IAAAG,2BAAsB,EAACF,6BAA6B,CAAC;IACvD,CAAC,CAAC;EACJ;AACF","ignoreList":[]}
|
package/build/render-hook.js
CHANGED
|
@@ -33,7 +33,7 @@ function renderHook(renderCallback, options) {
|
|
|
33
33
|
detectHostComponentNames: false
|
|
34
34
|
});
|
|
35
35
|
function rerender(rerenderCallbackProps) {
|
|
36
|
-
return baseRerender(
|
|
36
|
+
return baseRerender(/*#__PURE__*/_react.default.createElement(TestComponent, {
|
|
37
37
|
renderCallbackProps: rerenderCallbackProps
|
|
38
38
|
}));
|
|
39
39
|
}
|
package/build/render-hook.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","detectHostComponentNames","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n detectHostComponentNames: false,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC,OAAO;IACPc,wBAAwB,EAAE;EAC5B,CACF,CAAC;EAED,SAASL,QAAQA,CAACM,qBAA4B,EAAE;IAC9C,OAAOL,YAAY,
|
|
1
|
+
{"version":3,"file":"render-hook.js","names":["_react","_interopRequireDefault","require","_render","e","__esModule","default","renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","renderInternal","createElement","detectHostComponentNames","rerenderCallbackProps"],"sources":["../src/render-hook.tsx"],"sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport { renderInternal } from './render';\n\nexport type RenderHookResult<Result, Props> = {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n};\n\nexport type RenderHookOptions<Props> = {\n initialProps?: Props;\n wrapper?: ComponentType<any>;\n};\n\nexport function renderHook<Result, Props>(\n renderCallback: (props: Props) => Result,\n options?: RenderHookOptions<Props>,\n): RenderHookResult<Result, Props> {\n const initialProps = options?.initialProps;\n const wrapper = options?.wrapper;\n\n const result: React.MutableRefObject<Result | null> = React.createRef();\n\n function TestComponent({ renderCallbackProps }: { renderCallbackProps: Props }) {\n const renderResult = renderCallback(renderCallbackProps);\n\n React.useEffect(() => {\n result.current = renderResult;\n });\n\n return null;\n }\n\n const { rerender: baseRerender, unmount } = renderInternal(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n {\n wrapper,\n detectHostComponentNames: false,\n },\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(<TestComponent renderCallbackProps={rerenderCallbackProps} />);\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AAA0C,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAanC,SAASG,UAAUA,CACxBC,cAAwC,EACxCC,OAAkC,EACD;EACjC,MAAMC,YAAY,GAAGD,OAAO,EAAEC,YAAY;EAC1C,MAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAO;EAEhC,MAAMC,MAA6C,gBAAGC,cAAK,CAACC,SAAS,CAAC,CAAC;EAEvE,SAASC,aAAaA,CAAC;IAAEC;EAAoD,CAAC,EAAE;IAC9E,MAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAmB,CAAC;IAExDH,cAAK,CAACK,SAAS,CAAC,MAAM;MACpBN,MAAM,CAACO,OAAO,GAAGF,YAAY;IAC/B,CAAC,CAAC;IAEF,OAAO,IAAI;EACb;EAEA,MAAM;IAAEG,QAAQ,EAAEC,YAAY;IAAEC;EAAQ,CAAC,GAAG,IAAAC,sBAAc;EAAA;EACxD;EACAvB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;IAACC,mBAAmB,EAAEN;EAAa,CAAE,CAAC,EACpD;IACEC,OAAO;IACPc,wBAAwB,EAAE;EAC5B,CACF,CAAC;EAED,SAASL,QAAQA,CAACM,qBAA4B,EAAE;IAC9C,OAAOL,YAAY,cAACrB,MAAA,CAAAM,OAAA,CAAAkB,aAAA,CAACT,aAAa;MAACC,mBAAmB,EAAEU;IAAsB,CAAE,CAAC,CAAC;EACpF;;EAEA;EACA,OAAO;IAAEd,MAAM;IAAEQ,QAAQ;IAAEE;EAAQ,CAAC;AACtC","ignoreList":[]}
|