@testing-library/react-native 10.1.1 → 11.0.0-rc.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 (55) hide show
  1. package/README.md +4 -0
  2. package/build/fireEvent.js +15 -13
  3. package/build/fireEvent.js.map +1 -1
  4. package/build/helpers/errors.js +1 -3
  5. package/build/helpers/errors.js.map +1 -1
  6. package/build/helpers/matchers/matchArrayProp.d.ts +8 -0
  7. package/build/helpers/matchers/matchArrayProp.js +26 -0
  8. package/build/helpers/matchers/matchArrayProp.js.map +1 -0
  9. package/build/helpers/matchers/matchObjectProp.d.ts +12 -0
  10. package/build/helpers/matchers/matchObjectProp.js +27 -0
  11. package/build/helpers/matchers/matchObjectProp.js.map +1 -0
  12. package/build/helpers/matchers/matchStringProp.d.ts +9 -0
  13. package/build/helpers/matchers/matchStringProp.js +26 -0
  14. package/build/helpers/matchers/matchStringProp.js.map +1 -0
  15. package/build/helpers/timers.js +12 -2
  16. package/build/helpers/timers.js.map +1 -1
  17. package/build/index.flow.js +6 -24
  18. package/build/queries/a11yState.d.ts +18 -0
  19. package/build/queries/a11yState.js +53 -0
  20. package/build/queries/a11yState.js.map +1 -0
  21. package/build/queries/a11yValue.d.ts +24 -0
  22. package/build/queries/a11yValue.js +53 -0
  23. package/build/queries/a11yValue.js.map +1 -0
  24. package/build/queries/hintText.d.ts +24 -0
  25. package/build/queries/hintText.js +61 -0
  26. package/build/queries/hintText.js.map +1 -0
  27. package/build/queries/labelText.d.ts +12 -0
  28. package/build/queries/labelText.js +39 -0
  29. package/build/queries/labelText.js.map +1 -0
  30. package/build/queries/makeQueries.d.ts +6 -6
  31. package/build/queries/makeQueries.js +4 -36
  32. package/build/queries/makeQueries.js.map +1 -1
  33. package/build/queries/role.d.ts +12 -0
  34. package/build/queries/role.js +39 -0
  35. package/build/queries/role.js.map +1 -0
  36. package/build/queries/text.js +1 -3
  37. package/build/queries/text.js.map +1 -1
  38. package/build/render.d.ts +106 -64
  39. package/build/renderHook.js +2 -2
  40. package/build/renderHook.js.map +1 -1
  41. package/build/screen.js +24 -12
  42. package/build/screen.js.map +1 -1
  43. package/build/waitFor.js +1 -1
  44. package/build/waitFor.js.map +1 -1
  45. package/build/within.d.ts +106 -64
  46. package/build/within.js +16 -4
  47. package/build/within.js.map +1 -1
  48. package/package.json +21 -17
  49. package/typings/index.flow.js +6 -24
  50. package/build/queries/a11yAPI.d.ts +0 -66
  51. package/build/queries/a11yAPI.js +0 -94
  52. package/build/queries/a11yAPI.js.map +0 -1
  53. package/build/queries/makeA11yQuery.d.ts +0 -13
  54. package/build/queries/makeA11yQuery.js +0 -80
  55. package/build/queries/makeA11yQuery.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/renderHook.tsx"],"names":["renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","rerenderCallbackProps"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAeO,SAASA,UAAT,CACLC,cADK,EAELC,OAFK,EAG4B;AACjC,QAAMC,YAAY,GAAGD,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEC,YAA9B;AACA,QAAMC,OAAO,GAAGF,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEE,OAAzB;;AAEA,QAAMC,MAA6C,gBAAGC,eAAMC,SAAN,EAAtD;;AAEA,WAASC,aAAT,CAAuB;AACrBC,IAAAA;AADqB,GAAvB,EAIG;AACD,UAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAD,CAAnC;;AAEAH,mBAAMK,SAAN,CAAgB,MAAM;AACpBN,MAAAA,MAAM,CAACO,OAAP,GAAiBF,YAAjB;AACD,KAFD;;AAIA,WAAO,IAAP;AACD;;AAED,QAAM;AAAEG,IAAAA,QAAQ,EAAEC,YAAZ;AAA0BC,IAAAA;AAA1B,MAAsC;AAAA;AAC1C;AACA,+BAAC,aAAD;AAAe,IAAA,mBAAmB,EAAEZ;AAApC,IAF0C,EAG1C;AAAEC,IAAAA;AAAF,GAH0C,CAA5C;;AAMA,WAASS,QAAT,CAAkBG,qBAAlB,EAAgD;AAC9C,WAAOF,YAAY,eACjB,6BAAC,aAAD;AAAe,MAAA,mBAAmB,EAAEE;AAApC,MADiB,CAAnB;AAGD,GA9BgC,CAgCjC;;;AACA,SAAO;AAAEX,IAAAA,MAAF;AAAUQ,IAAAA,QAAV;AAAoBE,IAAAA;AAApB,GAAP;AACD","sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport render from './render';\n\ninterface RenderHookResult<Result, Props> {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n}\n\ntype RenderHookOptions<Props> = Props extends object | string | number | boolean\n ? {\n initialProps: Props;\n wrapper?: ComponentType<any>;\n }\n : { wrapper?: ComponentType<any>; initialProps?: never } | undefined;\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({\n renderCallbackProps,\n }: {\n renderCallbackProps: Props;\n }) {\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 } = render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n { wrapper }\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(\n <TestComponent renderCallbackProps={rerenderCallbackProps} />\n );\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"file":"renderHook.js"}
1
+ {"version":3,"sources":["../src/renderHook.tsx"],"names":["renderHook","renderCallback","options","initialProps","wrapper","result","React","createRef","TestComponent","renderCallbackProps","renderResult","useEffect","current","rerender","baseRerender","unmount","rerenderCallbackProps"],"mappings":";;;;;;;AAAA;;AAEA;;;;AAeO,SAASA,UAAT,CACLC,cADK,EAELC,OAFK,EAG4B;AACjC,QAAMC,YAAY,GAAGD,OAAO,EAAEC,YAA9B;AACA,QAAMC,OAAO,GAAGF,OAAO,EAAEE,OAAzB;;AAEA,QAAMC,MAA6C,gBAAGC,eAAMC,SAAN,EAAtD;;AAEA,WAASC,aAAT,CAAuB;AACrBC,IAAAA;AADqB,GAAvB,EAIG;AACD,UAAMC,YAAY,GAAGT,cAAc,CAACQ,mBAAD,CAAnC;;AAEAH,mBAAMK,SAAN,CAAgB,MAAM;AACpBN,MAAAA,MAAM,CAACO,OAAP,GAAiBF,YAAjB;AACD,KAFD;;AAIA,WAAO,IAAP;AACD;;AAED,QAAM;AAAEG,IAAAA,QAAQ,EAAEC,YAAZ;AAA0BC,IAAAA;AAA1B,MAAsC;AAAA;AAC1C;AACA,+BAAC,aAAD;AAAe,IAAA,mBAAmB,EAAEZ;AAApC,IAF0C,EAG1C;AAAEC,IAAAA;AAAF,GAH0C,CAA5C;;AAMA,WAASS,QAAT,CAAkBG,qBAAlB,EAAgD;AAC9C,WAAOF,YAAY,eACjB,6BAAC,aAAD;AAAe,MAAA,mBAAmB,EAAEE;AAApC,MADiB,CAAnB;AAGD,GA9BgC,CAgCjC;;;AACA,SAAO;AAAEX,IAAAA,MAAF;AAAUQ,IAAAA,QAAV;AAAoBE,IAAAA;AAApB,GAAP;AACD","sourcesContent":["import React from 'react';\nimport type { ComponentType } from 'react';\nimport render from './render';\n\ninterface RenderHookResult<Result, Props> {\n rerender: (props: Props) => void;\n result: { current: Result };\n unmount: () => void;\n}\n\ntype RenderHookOptions<Props> = Props extends object | string | number | boolean\n ? {\n initialProps: Props;\n wrapper?: ComponentType<any>;\n }\n : { wrapper?: ComponentType<any>; initialProps?: never } | undefined;\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({\n renderCallbackProps,\n }: {\n renderCallbackProps: Props;\n }) {\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 } = render(\n // @ts-expect-error since option can be undefined, initialProps can be undefined when it should'nt\n <TestComponent renderCallbackProps={initialProps} />,\n { wrapper }\n );\n\n function rerender(rerenderCallbackProps: Props) {\n return baseRerender(\n <TestComponent renderCallbackProps={rerenderCallbackProps} />\n );\n }\n\n // @ts-expect-error result is ill typed because ref is initialized to null\n return { result, rerender, unmount };\n}\n"],"file":"renderHook.js"}
package/build/screen.js CHANGED
@@ -33,42 +33,54 @@ const defaultScreen = {
33
33
  queryAllByLabelText: notImplemented,
34
34
  findByLabelText: notImplemented,
35
35
  findAllByLabelText: notImplemented,
36
- getByA11yHint: notImplemented,
37
36
  getByHintText: notImplemented,
38
- getAllByA11yHint: notImplemented,
39
37
  getAllByHintText: notImplemented,
40
- queryByA11yHint: notImplemented,
41
38
  queryByHintText: notImplemented,
42
- queryAllByA11yHint: notImplemented,
43
39
  queryAllByHintText: notImplemented,
44
- findByA11yHint: notImplemented,
45
40
  findByHintText: notImplemented,
46
- findAllByA11yHint: notImplemented,
47
41
  findAllByHintText: notImplemented,
42
+ getByA11yHint: notImplemented,
43
+ getAllByA11yHint: notImplemented,
44
+ queryByA11yHint: notImplemented,
45
+ queryAllByA11yHint: notImplemented,
46
+ findByA11yHint: notImplemented,
47
+ findAllByA11yHint: notImplemented,
48
+ getByAccessibilityHint: notImplemented,
49
+ getAllByAccessibilityHint: notImplemented,
50
+ queryByAccessibilityHint: notImplemented,
51
+ queryAllByAccessibilityHint: notImplemented,
52
+ findByAccessibilityHint: notImplemented,
53
+ findAllByAccessibilityHint: notImplemented,
48
54
  getByRole: notImplemented,
49
55
  getAllByRole: notImplemented,
50
56
  queryByRole: notImplemented,
51
57
  queryAllByRole: notImplemented,
52
58
  findByRole: notImplemented,
53
59
  findAllByRole: notImplemented,
54
- getByA11yStates: notImplemented,
55
- getAllByA11yStates: notImplemented,
56
- queryByA11yStates: notImplemented,
57
- queryAllByA11yStates: notImplemented,
58
- findByA11yStates: notImplemented,
59
- findAllByA11yStates: notImplemented,
60
60
  getByA11yState: notImplemented,
61
61
  getAllByA11yState: notImplemented,
62
62
  queryByA11yState: notImplemented,
63
63
  queryAllByA11yState: notImplemented,
64
64
  findByA11yState: notImplemented,
65
65
  findAllByA11yState: notImplemented,
66
+ getByAccessibilityState: notImplemented,
67
+ getAllByAccessibilityState: notImplemented,
68
+ queryByAccessibilityState: notImplemented,
69
+ queryAllByAccessibilityState: notImplemented,
70
+ findByAccessibilityState: notImplemented,
71
+ findAllByAccessibilityState: notImplemented,
66
72
  getByA11yValue: notImplemented,
67
73
  getAllByA11yValue: notImplemented,
68
74
  queryByA11yValue: notImplemented,
69
75
  queryAllByA11yValue: notImplemented,
70
76
  findByA11yValue: notImplemented,
71
77
  findAllByA11yValue: notImplemented,
78
+ getByAccessibilityValue: notImplemented,
79
+ getAllByAccessibilityValue: notImplemented,
80
+ queryByAccessibilityValue: notImplemented,
81
+ queryAllByAccessibilityValue: notImplemented,
82
+ findByAccessibilityValue: notImplemented,
83
+ findAllByAccessibilityValue: notImplemented,
72
84
  UNSAFE_getByProps: notImplemented,
73
85
  UNSAFE_getAllByProps: notImplemented,
74
86
  UNSAFE_queryByProps: notImplemented,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/screen.ts"],"names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","shallow","defaultScreen","container","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByA11yHint","getByHintText","getAllByA11yHint","getAllByHintText","queryByA11yHint","queryByHintText","queryAllByA11yHint","queryAllByHintText","findByA11yHint","findByHintText","findAllByA11yHint","findAllByHintText","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByA11yStates","getAllByA11yStates","queryByA11yStates","queryAllByA11yStates","findByA11yStates","findAllByA11yStates","getByA11yState","getAllByA11yState","queryByA11yState","queryAllByA11yState","findByA11yState","findAllByA11yState","getByA11yValue","getAllByA11yValue","queryByA11yValue","queryAllByA11yValue","findByA11yValue","findAllByA11yValue","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","setRenderResult","output","clearRenderResult"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAArB;;AAEA,MAAMC,cAAc,GAAG,MAAM;AAC3B,QAAM,IAAIC,KAAJ,CAAUF,YAAV,CAAN;AACD,CAFD;;AAIA,MAAMG,mBAAmB,GAAG,MAAM;AAChC,QAAM,IAAID,KAAJ,CAAUF,YAAV,CAAN;AACD,CAFD;;AAGAG,mBAAmB,CAACC,OAApB,GAA8BH,cAA9B;AAEA,MAAMI,aAA2B,GAAG;AAClC,MAAIC,SAAJ,GAAmC;AACjC,UAAM,IAAIJ,KAAJ,CAAUF,YAAV,CAAN;AACD,GAHiC;;AAIlCO,EAAAA,KAAK,EAAEJ,mBAJ2B;AAKlCK,EAAAA,MAAM,EAAEP,cAL0B;AAMlCQ,EAAAA,OAAO,EAAER,cANyB;AAOlCS,EAAAA,QAAQ,EAAET,cAPwB;AAQlCU,EAAAA,MAAM,EAAEV,cAR0B;AASlCW,EA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vE,cArEc;AAsElCwE,EAAAA,qBAAqB,EAAExE,cAtEW;AAuElCyE,EAAAA,WAAW,EAAEzE,cAvEqB;AAwElC0E,EAAAA,cAAc,EAAE1E,cAxEkB;AAyElC2E,EAAAA,aAAa,EAAE3E,cAzEmB;AA0ElC4E,EAAAA,gBAAgB,EAAE5E,cA1EgB;AA2ElC6E,EAAAA,YAAY,EAAE7E,cA3EoB;AA4ElC8E,EAAAA,eAAe,EAAE9E,cA5EiB;AA6ElC+E,EAAAA,SAAS,EAAE/E,cA7EuB;AA8ElCgF,EAAAA,YAAY,EAAEhF,cA9EoB;AA+ElCiF,EAAAA,WAAW,EAAEjF,cA/EqB;AAgFlCkF,EAAAA,cAAc,EAAElF,cAhFkB;AAiFlCmF,EAAAA,UAAU,EAAEnF,cAjFsB;AAkFlCoF,EAAAA,aAAa,EAAEpF;AAlFmB,CAApC;AAqFO,IAAIqF,MAAoB,GAAGjF,aAA3B;;;AAEA,SAASkF,eAAT,CAAyBC,MAAzB,EAA+C;AACpD,mBAAAF,MAAM,GAAGE,MAAT;AACD;;AAEM,SAASC,iBAAT,GAA6B;AAClC,mBAAAH,MAAM,GAAGjF,aAAT;AACD","sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\nnotImplementedDebug.shallow = notImplemented;\n\nconst defaultScreen: RenderResult = {\n get container(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByA11yHint: notImplemented,\n getByHintText: notImplemented,\n getAllByA11yHint: notImplemented,\n getAllByHintText: notImplemented,\n queryByA11yHint: notImplemented,\n queryByHintText: notImplemented,\n queryAllByA11yHint: notImplemented,\n queryAllByHintText: notImplemented,\n findByA11yHint: notImplemented,\n findByHintText: notImplemented,\n findAllByA11yHint: notImplemented,\n findAllByHintText: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByA11yStates: notImplemented,\n getAllByA11yStates: notImplemented,\n queryByA11yStates: notImplemented,\n queryAllByA11yStates: notImplemented,\n findByA11yStates: notImplemented,\n findAllByA11yStates: notImplemented,\n getByA11yState: notImplemented,\n getAllByA11yState: notImplemented,\n queryByA11yState: notImplemented,\n queryAllByA11yState: notImplemented,\n findByA11yState: notImplemented,\n findAllByA11yState: notImplemented,\n getByA11yValue: notImplemented,\n getAllByA11yValue: notImplemented,\n queryByA11yValue: notImplemented,\n queryAllByA11yValue: notImplemented,\n findByA11yValue: notImplemented,\n findAllByA11yValue: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: RenderResult = defaultScreen;\n\nexport function setRenderResult(output: RenderResult) {\n screen = output;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"file":"screen.js"}
1
+ {"version":3,"sources":["../src/screen.ts"],"names":["SCREEN_ERROR","notImplemented","Error","notImplementedDebug","shallow","defaultScreen","container","debug","update","unmount","rerender","toJSON","getByLabelText","getAllByLabelText","queryByLabelText","queryAllByLabelText","findByLabelText","findAllByLabelText","getByHintText","getAllByHintText","queryByHintText","queryAllByHintText","findByHintText","findAllByHintText","getByA11yHint","getAllByA11yHint","queryByA11yHint","queryAllByA11yHint","findByA11yHint","findAllByA11yHint","getByAccessibilityHint","getAllByAccessibilityHint","queryByAccessibilityHint","queryAllByAccessibilityHint","findByAccessibilityHint","findAllByAccessibilityHint","getByRole","getAllByRole","queryByRole","queryAllByRole","findByRole","findAllByRole","getByA11yState","getAllByA11yState","queryByA11yState","queryAllByA11yState","findByA11yState","findAllByA11yState","getByAccessibilityState","getAllByAccessibilityState","queryByAccessibilityState","queryAllByAccessibilityState","findByAccessibilityState","findAllByAccessibilityState","getByA11yValue","getAllByA11yValue","queryByA11yValue","queryAllByA11yValue","findByA11yValue","findAllByA11yValue","getByAccessibilityValue","getAllByAccessibilityValue","queryByAccessibilityValue","queryAllByAccessibilityValue","findByAccessibilityValue","findAllByAccessibilityValue","UNSAFE_getByProps","UNSAFE_getAllByProps","UNSAFE_queryByProps","UNSAFE_queryAllByProps","UNSAFE_getByType","UNSAFE_getAllByType","UNSAFE_queryByType","UNSAFE_queryAllByType","getByPlaceholderText","getAllByPlaceholderText","queryByPlaceholderText","queryAllByPlaceholderText","findByPlaceholderText","findAllByPlaceholderText","getByDisplayValue","getAllByDisplayValue","queryByDisplayValue","queryAllByDisplayValue","findByDisplayValue","findAllByDisplayValue","getByTestId","getAllByTestId","queryByTestId","queryAllByTestId","findByTestId","findAllByTestId","getByText","getAllByText","queryByText","queryAllByText","findByText","findAllByText","screen","setRenderResult","output","clearRenderResult"],"mappings":";;;;;;;;AAGA,MAAMA,YAAY,GAAG,qCAArB;;AAEA,MAAMC,cAAc,GAAG,MAAM;AAC3B,QAAM,IAAIC,KAAJ,CAAUF,YAAV,CAAN;AACD,CAFD;;AAIA,MAAMG,mBAAmB,GAAG,MAAM;AAChC,QAAM,IAAID,KAAJ,CAAUF,YAAV,CAAN;AACD,CAFD;;AAGAG,mBAAmB,CAACC,OAApB,GAA8BH,cAA9B;AAEA,MAAMI,aAA2B,GAAG;AAClC,MAAIC,SAAJ,GAAmC;AACjC,UAAM,IAAIJ,KAAJ,CAAUF,YAAV,CAAN;AACD,GAHiC;;AAIlCO,EAAAA,KAAK,EAAEJ,mBAJ2B;AAKlCK,EAAAA,MAAM,EAAEP,cAL0B;AAMlCQ,EAAAA,OAAO,EAAER,cANyB;AAOlCS,EAAAA,QAAQ,EAAET,cAPwB;AAQlCU,EAAAA,MAAM,EAAEV,cAR0B;AASlCW,EAAAA,cAAc,EAAEX,cATkB;AAUlCY,EAAAA,iBAAiB,EAAEZ,cAVe;AAWlCa,EAAAA,gBAAgB,EAAEb,cAXgB;AAYlCc,EAAAA,mBAAmB,EAAEd,cAZa;AAalCe,EAAAA,eAAe,EAAEf,cAbiB;AAclCgB,EAAAA,kBAAkB,EAAEhB,cAdc;AAelCiB,EAAAA,aAAa,EAAEjB,cAfmB;AAgBlCkB,EAAAA,gBAAgB,EAAElB,cAhBgB;AAiBlCmB,EAAAA,eAAe,EAAEnB,cAjBiB;AAkBlCoB,EAAAA,kBAAkB,EAAEpB,cAlBc;AAmBlCqB,EAAAA,cAAc,EAAErB,cAnBkB;AAoBlCsB,EAAAA,iBAAiB,EAAEtB,cApBe;AAqBlCuB,EAAAA,aAAa,EAAEvB,cArBmB;AAsBlCwB,EAAAA,gBA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CoF,EAAAA,qBAAqB,EAAEpF,cAlFW;AAmFlCqF,EAAAA,WAAW,EAAErF,cAnFqB;AAoFlCsF,EAAAA,cAAc,EAAEtF,cApFkB;AAqFlCuF,EAAAA,aAAa,EAAEvF,cArFmB;AAsFlCwF,EAAAA,gBAAgB,EAAExF,cAtFgB;AAuFlCyF,EAAAA,YAAY,EAAEzF,cAvFoB;AAwFlC0F,EAAAA,eAAe,EAAE1F,cAxFiB;AAyFlC2F,EAAAA,SAAS,EAAE3F,cAzFuB;AA0FlC4F,EAAAA,YAAY,EAAE5F,cA1FoB;AA2FlC6F,EAAAA,WAAW,EAAE7F,cA3FqB;AA4FlC8F,EAAAA,cAAc,EAAE9F,cA5FkB;AA6FlC+F,EAAAA,UAAU,EAAE/F,cA7FsB;AA8FlCgG,EAAAA,aAAa,EAAEhG;AA9FmB,CAApC;AAiGO,IAAIiG,MAAoB,GAAG7F,aAA3B;;;AAEA,SAAS8F,eAAT,CAAyBC,MAAzB,EAA+C;AACpD,mBAAAF,MAAM,GAAGE,MAAT;AACD;;AAEM,SAASC,iBAAT,GAA6B;AAClC,mBAAAH,MAAM,GAAG7F,aAAT;AACD","sourcesContent":["import { ReactTestInstance } from 'react-test-renderer';\nimport { RenderResult } from './render';\n\nconst SCREEN_ERROR = '`render` method has not been called';\n\nconst notImplemented = () => {\n throw new Error(SCREEN_ERROR);\n};\n\nconst notImplementedDebug = () => {\n throw new Error(SCREEN_ERROR);\n};\nnotImplementedDebug.shallow = notImplemented;\n\nconst defaultScreen: RenderResult = {\n get container(): ReactTestInstance {\n throw new Error(SCREEN_ERROR);\n },\n debug: notImplementedDebug,\n update: notImplemented,\n unmount: notImplemented,\n rerender: notImplemented,\n toJSON: notImplemented,\n getByLabelText: notImplemented,\n getAllByLabelText: notImplemented,\n queryByLabelText: notImplemented,\n queryAllByLabelText: notImplemented,\n findByLabelText: notImplemented,\n findAllByLabelText: notImplemented,\n getByHintText: notImplemented,\n getAllByHintText: notImplemented,\n queryByHintText: notImplemented,\n queryAllByHintText: notImplemented,\n findByHintText: notImplemented,\n findAllByHintText: notImplemented,\n getByA11yHint: notImplemented,\n getAllByA11yHint: notImplemented,\n queryByA11yHint: notImplemented,\n queryAllByA11yHint: notImplemented,\n findByA11yHint: notImplemented,\n findAllByA11yHint: notImplemented,\n getByAccessibilityHint: notImplemented,\n getAllByAccessibilityHint: notImplemented,\n queryByAccessibilityHint: notImplemented,\n queryAllByAccessibilityHint: notImplemented,\n findByAccessibilityHint: notImplemented,\n findAllByAccessibilityHint: notImplemented,\n getByRole: notImplemented,\n getAllByRole: notImplemented,\n queryByRole: notImplemented,\n queryAllByRole: notImplemented,\n findByRole: notImplemented,\n findAllByRole: notImplemented,\n getByA11yState: notImplemented,\n getAllByA11yState: notImplemented,\n queryByA11yState: notImplemented,\n queryAllByA11yState: notImplemented,\n findByA11yState: notImplemented,\n findAllByA11yState: notImplemented,\n getByAccessibilityState: notImplemented,\n getAllByAccessibilityState: notImplemented,\n queryByAccessibilityState: notImplemented,\n queryAllByAccessibilityState: notImplemented,\n findByAccessibilityState: notImplemented,\n findAllByAccessibilityState: notImplemented,\n getByA11yValue: notImplemented,\n getAllByA11yValue: notImplemented,\n queryByA11yValue: notImplemented,\n queryAllByA11yValue: notImplemented,\n findByA11yValue: notImplemented,\n findAllByA11yValue: notImplemented,\n getByAccessibilityValue: notImplemented,\n getAllByAccessibilityValue: notImplemented,\n queryByAccessibilityValue: notImplemented,\n queryAllByAccessibilityValue: notImplemented,\n findByAccessibilityValue: notImplemented,\n findAllByAccessibilityValue: notImplemented,\n UNSAFE_getByProps: notImplemented,\n UNSAFE_getAllByProps: notImplemented,\n UNSAFE_queryByProps: notImplemented,\n UNSAFE_queryAllByProps: notImplemented,\n UNSAFE_getByType: notImplemented,\n UNSAFE_getAllByType: notImplemented,\n UNSAFE_queryByType: notImplemented,\n UNSAFE_queryAllByType: notImplemented,\n getByPlaceholderText: notImplemented,\n getAllByPlaceholderText: notImplemented,\n queryByPlaceholderText: notImplemented,\n queryAllByPlaceholderText: notImplemented,\n findByPlaceholderText: notImplemented,\n findAllByPlaceholderText: notImplemented,\n getByDisplayValue: notImplemented,\n getAllByDisplayValue: notImplemented,\n queryByDisplayValue: notImplemented,\n queryAllByDisplayValue: notImplemented,\n findByDisplayValue: notImplemented,\n findAllByDisplayValue: notImplemented,\n getByTestId: notImplemented,\n getAllByTestId: notImplemented,\n queryByTestId: notImplemented,\n queryAllByTestId: notImplemented,\n findByTestId: notImplemented,\n findAllByTestId: notImplemented,\n getByText: notImplemented,\n getAllByText: notImplemented,\n queryByText: notImplemented,\n queryAllByText: notImplemented,\n findByText: notImplemented,\n findAllByText: notImplemented,\n};\n\nexport let screen: RenderResult = defaultScreen;\n\nexport function setRenderResult(output: RenderResult) {\n screen = output;\n}\n\nexport function clearRenderResult() {\n screen = defaultScreen;\n}\n"],"file":"screen.js"}
package/build/waitFor.js CHANGED
@@ -134,7 +134,7 @@ function waitForInternal(expectation, {
134
134
  const result = expectation(); // @ts-ignore result can be a promise
135
135
  // eslint-disable-next-line promise/prefer-await-to-then
136
136
 
137
- if (typeof (result === null || result === void 0 ? void 0 : result.then) === 'function') {
137
+ if (typeof result?.then === 'function') {
138
138
  const promiseResult = result;
139
139
  promiseStatus = 'pending'; // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then
140
140
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/waitFor.ts"],"names":["DEFAULT_TIMEOUT","DEFAULT_INTERVAL","checkReactVersionAtLeast","major","minor","React","version","undefined","actualMajor","actualMinor","split","map","Number","waitForInternal","expectation","timeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","handleTimeout","usingFakeTimers","checkExpectation","fakeTimeRemaining","error","Error","jest","advanceTimersByTime","setInterval","checkRealTimersCallback","onDone","done","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","waitFor","options","ErrorWithStack","optionsWithStackTrace"],"mappings":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;AACnCA,QAAAA,SAAS,CAACc,KAAD,CAAT;AACD;;AACDM,MAAAA,MAAM,CAAC;AAAEG,QAAAA,IAAI,EAAE,OAAR;AAAiBT,QAAAA;AAAjB,OAAD,CAAN;AACD;AACF,GA/IM,CAAP;AAgJD;;AAEc,eAAee,OAAf,CACbjC,WADa,EAEbkC,OAFa,EAGD;AACZ;AACA,QAAM/B,eAAe,GAAG,IAAIgC,sBAAJ,CAAmB,mBAAnB,EAAwCF,OAAxC,CAAxB;AACA,QAAMG,qBAAqB,GAAG;AAAEjC,IAAAA,eAAF;AAAmB,OAAG+B;AAAtB,GAA9B;;AAEA,MAAI,CAAC9C,wBAAwB,CAAC,EAAD,EAAK,CAAL,CAA7B,EAAsC;AACpC,WAAOW,eAAe,CAACC,WAAD,EAAcoC,qBAAd,CAAtB;AACD;;AAED,MAAIR,MAAJ;AAEA,QAAM,kBAAI,YAAY;AACpBA,IAAAA,MAAM,GAAG,MAAM7B,eAAe,CAACC,WAAD,EAAcoC,qBAAd,CAA9B;AACD,GAFK,CAAN,CAXY,CAeZ;;AACA,SAAOR,MAAP;AACD","sourcesContent":["/* globals jest */\nimport * as React from 'react';\nimport act from './act';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n setImmediate,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\n\nconst DEFAULT_TIMEOUT = 1000;\nconst DEFAULT_INTERVAL = 50;\n\nfunction 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\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: unknown) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = DEFAULT_TIMEOUT,\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 const overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n // eslint-disable-next-line no-unmodified-loop-condition\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n // eslint-disable-next-line no-await-in-loop\n await new Promise((resolve) => setImmediate(resolve));\n }\n } else {\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(\n done: { type: 'result'; result: T } | { type: 'error'; error: unknown }\n ) {\n finished = true;\n clearTimeout(overallTimeoutTimer);\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-ignore result can be a promise\n // eslint-disable-next-line promise/prefer-await-to-then\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as any;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n }\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error;\n if (lastError) {\n error = lastError;\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 onTimeout(error);\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default async function waitFor<T>(\n expectation: () => T,\n options?: WaitForOptions\n): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n if (!checkReactVersionAtLeast(16, 9)) {\n return waitForInternal(expectation, optionsWithStackTrace);\n }\n\n let result: T;\n\n await act(async () => {\n result = await waitForInternal(expectation, optionsWithStackTrace);\n });\n\n // Either we have result or `waitFor` threw error\n return result!;\n}\n"],"file":"waitFor.js"}
1
+ {"version":3,"sources":["../src/waitFor.ts"],"names":["DEFAULT_TIMEOUT","DEFAULT_INTERVAL","checkReactVersionAtLeast","major","minor","React","version","undefined","actualMajor","actualMinor","split","map","Number","waitForInternal","expectation","timeout","interval","stackTraceError","onTimeout","TypeError","Promise","resolve","reject","lastError","intervalId","finished","promiseStatus","overallTimeoutTimer","handleTimeout","usingFakeTimers","checkExpectation","fakeTimeRemaining","error","Error","jest","advanceTimersByTime","setInterval","checkRealTimersCallback","onDone","done","clearInterval","type","result","then","promiseResult","resolvedValue","rejectedValue","waitFor","options","ErrorWithStack","optionsWithStackTrace"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;;;;;;;AAJA;AAWA,MAAMA,eAAe,GAAG,IAAxB;AACA,MAAMC,gBAAgB,GAAG,EAAzB;;AAEA,SAASC,wBAAT,CAAkCC,KAAlC,EAAiDC,KAAjD,EAAyE;AACvE,MAAIC,KAAK,CAACC,OAAN,KAAkBC,SAAtB,EAAiC,OAAO,KAAP;AACjC,QAAM,CAACC,WAAD,EAAcC,WAAd,IAA6BJ,KAAK,CAACC,OAAN,CAAcI,KAAd,CAAoB,GAApB,EAAyBC,GAAzB,CAA6BC,MAA7B,CAAnC;AAEA,SAAOJ,WAAW,GAAGL,KAAd,IAAwBK,WAAW,KAAKL,KAAhB,IAAyBM,WAAW,IAAIL,KAAvE;AACD;;AASD,SAASS,eAAT,CACEC,WADF,EAEE;AACEC,EAAAA,OAAO,GAAGf,eADZ;AAEEgB,EAAAA,QAAQ,GAAGf,gBAFb;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Ae,CAACC,WAAD,EAAcoC,qBAAd,CAA9B;AACD,GAFK,CAAN,CAXY,CAeZ;;AACA,SAAOR,MAAP;AACD","sourcesContent":["/* globals jest */\nimport * as React from 'react';\nimport act from './act';\nimport { ErrorWithStack, copyStackTrace } from './helpers/errors';\nimport {\n setTimeout,\n clearTimeout,\n setImmediate,\n jestFakeTimersAreEnabled,\n} from './helpers/timers';\n\nconst DEFAULT_TIMEOUT = 1000;\nconst DEFAULT_INTERVAL = 50;\n\nfunction 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\nexport type WaitForOptions = {\n timeout?: number;\n interval?: number;\n stackTraceError?: ErrorWithStack;\n onTimeout?: (error: unknown) => Error;\n};\n\nfunction waitForInternal<T>(\n expectation: () => T,\n {\n timeout = DEFAULT_TIMEOUT,\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 const overallTimeoutTimer = setTimeout(handleTimeout, timeout);\n\n const usingFakeTimers = jestFakeTimersAreEnabled();\n\n if (usingFakeTimers) {\n checkExpectation();\n // this is a dangerous rule to disable because it could lead to an\n // infinite loop. However, eslint isn't smart enough to know that we're\n // setting finished inside `onDone` which will be called when we're done\n // waiting or when we've timed out.\n // eslint-disable-next-line no-unmodified-loop-condition\n let fakeTimeRemaining = timeout;\n while (!finished) {\n if (!jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using fake timers to real timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to real timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n reject(error);\n return;\n }\n\n // when fake timers are used we want to simulate the interval time passing\n if (fakeTimeRemaining <= 0) {\n return;\n } else {\n fakeTimeRemaining -= interval;\n }\n\n // we *could* (maybe should?) use `advanceTimersToNextTimer` but it's\n // possible that could make this loop go on forever if someone is using\n // third party code that's setting up recursive timers so rapidly that\n // the user's timer's don't get a chance to resolve. So we'll advance\n // by an interval instead. (We have a test for this case).\n jest.advanceTimersByTime(interval);\n\n // It's really important that checkExpectation is run *before* we flush\n // in-flight promises. To be honest, I'm not sure why, and I can't quite\n // think of a way to reproduce the problem in a test, but I spent\n // an entire day banging my head against a wall on this.\n checkExpectation();\n\n // In this rare case, we *need* to wait for in-flight promises\n // to resolve before continuing. We don't need to take advantage\n // of parallelization so we're fine.\n // https://stackoverflow.com/a/59243586/971592\n // eslint-disable-next-line no-await-in-loop\n await new Promise((resolve) => setImmediate(resolve));\n }\n } else {\n intervalId = setInterval(checkRealTimersCallback, interval);\n checkExpectation();\n }\n\n function onDone(\n done: { type: 'result'; result: T } | { type: 'error'; error: unknown }\n ) {\n finished = true;\n clearTimeout(overallTimeoutTimer);\n\n if (!usingFakeTimers) {\n clearInterval(intervalId);\n }\n\n if (done.type === 'error') {\n reject(done.error);\n } else {\n resolve(done.result);\n }\n }\n\n function checkRealTimersCallback() {\n if (jestFakeTimersAreEnabled()) {\n const error = new Error(\n `Changed from using real timers to fake timers while using waitFor. This is not allowed and will result in very strange behavior. Please ensure you're awaiting all async things your test is doing before changing to fake timers. For more info, please go to https://github.com/testing-library/dom-testing-library/issues/830`\n );\n if (stackTraceError) {\n copyStackTrace(error, stackTraceError);\n }\n return reject(error);\n } else {\n return checkExpectation();\n }\n }\n\n function checkExpectation() {\n if (promiseStatus === 'pending') return;\n try {\n const result = expectation();\n\n // @ts-ignore result can be a promise\n // eslint-disable-next-line promise/prefer-await-to-then\n if (typeof result?.then === 'function') {\n const promiseResult: Promise<T> = result as any;\n promiseStatus = 'pending';\n // eslint-disable-next-line promise/catch-or-return, promise/prefer-await-to-then\n promiseResult.then(\n (resolvedValue) => {\n promiseStatus = 'resolved';\n onDone({ type: 'result', result: resolvedValue });\n return;\n },\n (rejectedValue) => {\n promiseStatus = 'rejected';\n lastError = rejectedValue;\n return;\n }\n );\n } else {\n onDone({ type: 'result', result: result });\n }\n // If `callback` throws, wait for the next mutation, interval, or timeout.\n } catch (error) {\n // Save the most recent callback error to reject the promise with it in the event of a timeout\n lastError = error;\n }\n }\n\n function handleTimeout() {\n let error;\n if (lastError) {\n error = lastError;\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 onTimeout(error);\n }\n onDone({ type: 'error', error });\n }\n });\n}\n\nexport default async function waitFor<T>(\n expectation: () => T,\n options?: WaitForOptions\n): Promise<T> {\n // Being able to display a useful stack trace requires generating it before doing anything async\n const stackTraceError = new ErrorWithStack('STACK_TRACE_ERROR', waitFor);\n const optionsWithStackTrace = { stackTraceError, ...options };\n\n if (!checkReactVersionAtLeast(16, 9)) {\n return waitForInternal(expectation, optionsWithStackTrace);\n }\n\n let result: T;\n\n await act(async () => {\n result = await waitForInternal(expectation, optionsWithStackTrace);\n });\n\n // Either we have result or `waitFor` threw error\n return result!;\n}\n"],"file":"waitFor.js"}
package/build/within.d.ts CHANGED
@@ -1,94 +1,136 @@
1
1
  /// <reference types="react" />
2
2
  import type { ReactTestInstance } from 'react-test-renderer';
3
3
  export declare function within(instance: ReactTestInstance): {
4
- getByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance;
5
- getAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
6
- queryByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance | null;
7
- queryAllByLabelText: (label: import("./matches").TextMatch) => ReactTestInstance[];
8
- findByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
9
- findAllByLabelText: (label: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
10
- getByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
11
- getByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance;
12
- getAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
13
- getAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
14
- queryByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
15
- queryByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance | null;
16
- queryAllByA11yHint: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
17
- queryAllByHintText: (a11yHint: import("./matches").TextMatch) => ReactTestInstance[];
18
- findByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
19
- findByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
20
- findAllByA11yHint: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
21
- findAllByHintText: (a11yHint: import("./matches").TextMatch, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
22
- getByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance;
23
- getAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
24
- queryByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance | null;
25
- queryAllByRole: (role: RegExp | import("react-native").AccessibilityRole) => ReactTestInstance[];
26
- findByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
27
- findAllByRole: (role: import("react-native").AccessibilityRole, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
28
- getByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance;
29
- getAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
30
- queryByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance | null;
31
- queryAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState | (keyof import("react-native").AccessibilityState)[]) => ReactTestInstance[];
32
- findByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
33
- findAllByA11yStates: (accessibilityStateKey: keyof import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
34
- getByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance;
35
- getAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
36
- queryByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance | null;
37
- queryAllByA11yState: (accessibilityState: import("react-native").AccessibilityState) => ReactTestInstance[];
38
- findByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
39
- findAllByA11yState: (accessibilityState: import("react-native").AccessibilityState, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
40
- getByA11yValue: (a11yValue: {
4
+ UNSAFE_getByProps: (props: {
5
+ [key: string]: any;
6
+ }) => ReactTestInstance;
7
+ UNSAFE_getAllByProps: (props: {
8
+ [key: string]: any;
9
+ }) => ReactTestInstance[];
10
+ UNSAFE_queryByProps: (props: {
11
+ [key: string]: any;
12
+ }) => ReactTestInstance | null;
13
+ UNSAFE_queryAllByProps: (props: {
14
+ [key: string]: any;
15
+ }) => ReactTestInstance[];
16
+ UNSAFE_getByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance;
17
+ UNSAFE_getAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
18
+ UNSAFE_queryByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance | null;
19
+ UNSAFE_queryAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
20
+ getByA11yValue: import("./queries/makeQueries").GetByQuery<{
41
21
  min?: number | undefined;
42
22
  max?: number | undefined;
43
23
  now?: number | undefined;
44
24
  text?: string | undefined;
45
- }) => ReactTestInstance;
46
- getAllByA11yValue: (a11yValue: {
25
+ }, void>;
26
+ getAllByA11yValue: import("./queries/makeQueries").GetAllByQuery<{
47
27
  min?: number | undefined;
48
28
  max?: number | undefined;
49
29
  now?: number | undefined;
50
30
  text?: string | undefined;
51
- }) => ReactTestInstance[];
52
- queryByA11yValue: (a11yValue: {
31
+ }, void>;
32
+ queryByA11yValue: import("./queries/makeQueries").QueryByQuery<{
53
33
  min?: number | undefined;
54
34
  max?: number | undefined;
55
35
  now?: number | undefined;
56
36
  text?: string | undefined;
57
- }) => ReactTestInstance | null;
58
- queryAllByA11yValue: (a11yValue: {
37
+ }, void>;
38
+ queryAllByA11yValue: import("./queries/makeQueries").QueryAllByQuery<{
59
39
  min?: number | undefined;
60
40
  max?: number | undefined;
61
41
  now?: number | undefined;
62
42
  text?: string | undefined;
63
- }) => ReactTestInstance[];
64
- findByA11yValue: (a11yValue: {
43
+ }, void>;
44
+ findByA11yValue: import("./queries/makeQueries").FindByQuery<{
65
45
  min?: number | undefined;
66
46
  max?: number | undefined;
67
47
  now?: number | undefined;
68
48
  text?: string | undefined;
69
- }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance>;
70
- findAllByA11yValue: (a11yValue: {
49
+ }, void>;
50
+ findAllByA11yValue: import("./queries/makeQueries").FindAllByQuery<{
71
51
  min?: number | undefined;
72
52
  max?: number | undefined;
73
53
  now?: number | undefined;
74
54
  text?: string | undefined;
75
- }, waitForOptions?: import("./waitFor").WaitForOptions | undefined) => Promise<ReactTestInstance[]>;
76
- UNSAFE_getByProps: (props: {
77
- [key: string]: any;
78
- }) => ReactTestInstance;
79
- UNSAFE_getAllByProps: (props: {
80
- [key: string]: any;
81
- }) => ReactTestInstance[];
82
- UNSAFE_queryByProps: (props: {
83
- [key: string]: any;
84
- }) => ReactTestInstance | null;
85
- UNSAFE_queryAllByProps: (props: {
86
- [key: string]: any;
87
- }) => ReactTestInstance[];
88
- UNSAFE_getByType: <P>(type: import("react").ComponentType<P>) => ReactTestInstance;
89
- UNSAFE_getAllByType: <P_1>(type: import("react").ComponentType<P_1>) => ReactTestInstance[];
90
- UNSAFE_queryByType: <P_2>(type: import("react").ComponentType<P_2>) => ReactTestInstance | null;
91
- UNSAFE_queryAllByType: <P_3>(type: import("react").ComponentType<P_3>) => ReactTestInstance[];
55
+ }, void>;
56
+ getByAccessibilityValue: import("./queries/makeQueries").GetByQuery<{
57
+ min?: number | undefined;
58
+ max?: number | undefined;
59
+ now?: number | undefined;
60
+ text?: string | undefined;
61
+ }, void>;
62
+ getAllByAccessibilityValue: import("./queries/makeQueries").GetAllByQuery<{
63
+ min?: number | undefined;
64
+ max?: number | undefined;
65
+ now?: number | undefined;
66
+ text?: string | undefined;
67
+ }, void>;
68
+ queryByAccessibilityValue: import("./queries/makeQueries").QueryByQuery<{
69
+ min?: number | undefined;
70
+ max?: number | undefined;
71
+ now?: number | undefined;
72
+ text?: string | undefined;
73
+ }, void>;
74
+ queryAllByAccessibilityValue: import("./queries/makeQueries").QueryAllByQuery<{
75
+ min?: number | undefined;
76
+ max?: number | undefined;
77
+ now?: number | undefined;
78
+ text?: string | undefined;
79
+ }, void>;
80
+ findByAccessibilityValue: import("./queries/makeQueries").FindByQuery<{
81
+ min?: number | undefined;
82
+ max?: number | undefined;
83
+ now?: number | undefined;
84
+ text?: string | undefined;
85
+ }, void>;
86
+ findAllByAccessibilityValue: import("./queries/makeQueries").FindAllByQuery<{
87
+ min?: number | undefined;
88
+ max?: number | undefined;
89
+ now?: number | undefined;
90
+ text?: string | undefined;
91
+ }, void>;
92
+ getByA11yState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, void>;
93
+ getAllByA11yState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, void>;
94
+ queryByA11yState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, void>;
95
+ queryAllByA11yState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, void>;
96
+ findByA11yState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, void>;
97
+ findAllByA11yState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, void>;
98
+ getByAccessibilityState: import("./queries/makeQueries").GetByQuery<import("react-native").AccessibilityState, void>;
99
+ getAllByAccessibilityState: import("./queries/makeQueries").GetAllByQuery<import("react-native").AccessibilityState, void>;
100
+ queryByAccessibilityState: import("./queries/makeQueries").QueryByQuery<import("react-native").AccessibilityState, void>;
101
+ queryAllByAccessibilityState: import("./queries/makeQueries").QueryAllByQuery<import("react-native").AccessibilityState, void>;
102
+ findByAccessibilityState: import("./queries/makeQueries").FindByQuery<import("react-native").AccessibilityState, void>;
103
+ findAllByAccessibilityState: import("./queries/makeQueries").FindAllByQuery<import("react-native").AccessibilityState, void>;
104
+ getByRole: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
105
+ getAllByRole: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
106
+ queryByRole: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
107
+ queryAllByRole: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
108
+ findByRole: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
109
+ findAllByRole: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
110
+ getByHintText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
111
+ getAllByHintText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
112
+ queryByHintText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
113
+ queryAllByHintText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
114
+ findByHintText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
115
+ findAllByHintText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
116
+ getByA11yHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
117
+ getAllByA11yHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
118
+ queryByA11yHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
119
+ queryAllByA11yHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
120
+ findByA11yHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
121
+ findAllByA11yHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
122
+ getByAccessibilityHint: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
123
+ getAllByAccessibilityHint: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
124
+ queryByAccessibilityHint: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
125
+ queryAllByAccessibilityHint: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
126
+ findByAccessibilityHint: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
127
+ findAllByAccessibilityHint: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
128
+ getByLabelText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, void>;
129
+ getAllByLabelText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, void>;
130
+ queryByLabelText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, void>;
131
+ queryAllByLabelText: import("./queries/makeQueries").QueryAllByQuery<import("./matches").TextMatch, void>;
132
+ findByLabelText: import("./queries/makeQueries").FindByQuery<import("./matches").TextMatch, void>;
133
+ findAllByLabelText: import("./queries/makeQueries").FindAllByQuery<import("./matches").TextMatch, void>;
92
134
  getByPlaceholderText: import("./queries/makeQueries").GetByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
93
135
  getAllByPlaceholderText: import("./queries/makeQueries").GetAllByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
94
136
  queryByPlaceholderText: import("./queries/makeQueries").QueryByQuery<import("./matches").TextMatch, import("./queries/text").TextMatchOptions>;
package/build/within.js CHANGED
@@ -6,8 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getQueriesForElement = void 0;
7
7
  exports.within = within;
8
8
 
9
- var _a11yAPI = require("./queries/a11yAPI");
10
-
11
9
  var _text = require("./queries/text");
12
10
 
13
11
  var _testId = require("./queries/testId");
@@ -16,6 +14,16 @@ var _displayValue = require("./queries/displayValue");
16
14
 
17
15
  var _placeholderText = require("./queries/placeholderText");
18
16
 
17
+ var _labelText = require("./queries/labelText");
18
+
19
+ var _hintText = require("./queries/hintText");
20
+
21
+ var _role = require("./queries/role");
22
+
23
+ var _a11yState = require("./queries/a11yState");
24
+
25
+ var _a11yValue = require("./queries/a11yValue");
26
+
19
27
  var _unsafeType = require("./queries/unsafeType");
20
28
 
21
29
  var _unsafeProps = require("./queries/unsafeProps");
@@ -25,9 +33,13 @@ function within(instance) {
25
33
  ...(0, _testId.bindByTestIdQueries)(instance),
26
34
  ...(0, _displayValue.bindByDisplayValueQueries)(instance),
27
35
  ...(0, _placeholderText.bindByPlaceholderTextQueries)(instance),
36
+ ...(0, _labelText.bindByLabelTextQueries)(instance),
37
+ ...(0, _hintText.bindByHintTextQueries)(instance),
38
+ ...(0, _role.bindByRoleQueries)(instance),
39
+ ...(0, _a11yState.bindByA11yStateQueries)(instance),
40
+ ...(0, _a11yValue.bindByA11yValueQueries)(instance),
28
41
  ...(0, _unsafeType.bindUnsafeByTypeQueries)(instance),
29
- ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance),
30
- ...(0, _a11yAPI.a11yAPI)(instance)
42
+ ...(0, _unsafeProps.bindUnsafeByPropsQueries)(instance)
31
43
  };
32
44
  }
33
45
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,6BAAkBA,QAAlB,CADE;AAEL,OAAG,iCAAoBA,QAApB,CAFE;AAGL,OAAG,6CAA0BA,QAA1B,CAHE;AAIL,OAAG,mDAA6BA,QAA7B,CAJE;AAKL,OAAG,yCAAwBA,QAAxB,CALE;AAML,OAAG,2CAAyBA,QAAzB,CANE;AAOL,OAAG,sBAAQA,QAAR;AAPE,GAAP;AASD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { a11yAPI } from './queries/a11yAPI';\nimport { bindByTextQueries } from './queries/text';\nimport { bindByTestIdQueries } from './queries/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\nimport { bindUnsafeByTypeQueries } from './queries/unsafeType';\nimport { bindUnsafeByPropsQueries } from './queries/unsafeProps';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...bindByTextQueries(instance),\n ...bindByTestIdQueries(instance),\n ...bindByDisplayValueQueries(instance),\n ...bindByPlaceholderTextQueries(instance),\n ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n ...a11yAPI(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
1
+ {"version":3,"sources":["../src/within.ts"],"names":["within","instance","getQueriesForElement"],"mappings":";;;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,SAASA,MAAT,CAAgBC,QAAhB,EAA6C;AAClD,SAAO,EACL,GAAG,6BAAkBA,QAAlB,CADE;AAEL,OAAG,iCAAoBA,QAApB,CAFE;AAGL,OAAG,6CAA0BA,QAA1B,CAHE;AAIL,OAAG,mDAA6BA,QAA7B,CAJE;AAKL,OAAG,uCAAuBA,QAAvB,CALE;AAML,OAAG,qCAAsBA,QAAtB,CANE;AAOL,OAAG,6BAAkBA,QAAlB,CAPE;AAQL,OAAG,uCAAuBA,QAAvB,CARE;AASL,OAAG,uCAAuBA,QAAvB,CATE;AAUL,OAAG,yCAAwBA,QAAxB,CAVE;AAWL,OAAG,2CAAyBA,QAAzB;AAXE,GAAP;AAaD;;AAEM,MAAMC,oBAAoB,GAAGF,MAA7B","sourcesContent":["import type { ReactTestInstance } from 'react-test-renderer';\nimport { bindByTextQueries } from './queries/text';\nimport { bindByTestIdQueries } from './queries/testId';\nimport { bindByDisplayValueQueries } from './queries/displayValue';\nimport { bindByPlaceholderTextQueries } from './queries/placeholderText';\nimport { bindByLabelTextQueries } from './queries/labelText';\nimport { bindByHintTextQueries } from './queries/hintText';\nimport { bindByRoleQueries } from './queries/role';\nimport { bindByA11yStateQueries } from './queries/a11yState';\nimport { bindByA11yValueQueries } from './queries/a11yValue';\nimport { bindUnsafeByTypeQueries } from './queries/unsafeType';\nimport { bindUnsafeByPropsQueries } from './queries/unsafeProps';\n\nexport function within(instance: ReactTestInstance) {\n return {\n ...bindByTextQueries(instance),\n ...bindByTestIdQueries(instance),\n ...bindByDisplayValueQueries(instance),\n ...bindByPlaceholderTextQueries(instance),\n ...bindByLabelTextQueries(instance),\n ...bindByHintTextQueries(instance),\n ...bindByRoleQueries(instance),\n ...bindByA11yStateQueries(instance),\n ...bindByA11yValueQueries(instance),\n ...bindUnsafeByTypeQueries(instance),\n ...bindUnsafeByPropsQueries(instance),\n };\n}\n\nexport const getQueriesForElement = within;\n"],"file":"within.js"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@testing-library/react-native",
3
- "version": "10.1.1",
3
+ "version": "11.0.0-rc.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",
@@ -29,7 +29,7 @@
29
29
  "@babel/cli": "^7.8.4",
30
30
  "@babel/core": "^7.9.0",
31
31
  "@babel/plugin-proposal-class-properties": "^7.8.3",
32
- "@babel/plugin-transform-flow-strip-types": "^7.16.0",
32
+ "@babel/plugin-transform-flow-strip-types": "^7.18.0",
33
33
  "@babel/preset-env": "^7.9.6",
34
34
  "@babel/preset-flow": "^7.9.0",
35
35
  "@babel/preset-react": "^7.9.4",
@@ -37,22 +37,22 @@
37
37
  "@callstack/eslint-config": "^11.0.0",
38
38
  "@release-it/conventional-changelog": "^2.0.0",
39
39
  "@testing-library/jest-native": "~4.0.2",
40
- "@types/jest": "^27.0.0",
41
- "@types/react": "^17.0.0",
42
- "@types/react-native": "^0.66.6",
43
- "@types/react-test-renderer": "^17.0.0",
44
- "babel-jest": "^27.0.0",
40
+ "@types/jest": "^28.0.0",
41
+ "@types/react": "^18.0.0",
42
+ "@types/react-native": "^0.69.1",
43
+ "@types/react-test-renderer": "^18.0.0",
44
+ "babel-jest": "^28.0.0",
45
45
  "conventional-changelog-cli": "^2.0.11",
46
46
  "cp-cli": "^2.0.0",
47
47
  "dedent": "^0.7.0",
48
48
  "del-cli": "^3.0.1",
49
- "eslint": "^7.0.0",
50
- "flow-bin": "^0.141.0",
49
+ "eslint": "^7.32.0",
50
+ "flow-bin": "~0.170.0",
51
51
  "flow-copy-source": "^2.0.9",
52
- "jest": "^27.0.0",
53
- "react": "^17.0.2",
54
- "react-native": "^0.66.0",
55
- "react-test-renderer": "^17.0.2",
52
+ "jest": "^28.0.0",
53
+ "react": "^18.0.0",
54
+ "react-native": "~0.69.1",
55
+ "react-test-renderer": "^18.0.0",
56
56
  "release-it": "^14.0.3",
57
57
  "strip-ansi": "^6.0.0",
58
58
  "typescript": "^4.0.2"
@@ -68,6 +68,7 @@
68
68
  "scripts": {
69
69
  "clean": "del build",
70
70
  "test": "jest",
71
+ "test:ci": "jest --maxWorkers=2",
71
72
  "typecheck": "tsc",
72
73
  "flow": "flow",
73
74
  "copy-flowtypes": "cp typings/index.flow.js build",
@@ -82,12 +83,15 @@
82
83
  "prepare": "yarn build"
83
84
  },
84
85
  "jest": {
85
- "preset": "../jest-preset",
86
- "rootDir": "./src",
86
+ "preset": "./jest-preset",
87
+ "setupFiles": [
88
+ "./jestSetup.js"
89
+ ],
87
90
  "testPathIgnorePatterns": [
88
- "timerUtils"
91
+ "timerUtils",
92
+ "examples/"
89
93
  ],
90
- "testTimeout": 30000,
94
+ "testTimeout": 60000,
91
95
  "transformIgnorePatterns": [
92
96
  "/node_modules/(?!(@react-native|react-native)/).*/"
93
97
  ]
@@ -56,16 +56,6 @@ declare type A11yState = {|
56
56
  expanded?: boolean,
57
57
  |};
58
58
 
59
- declare type A11yStates =
60
- | 'disabled'
61
- | 'selected'
62
- | 'checked'
63
- | 'unchecked'
64
- | 'busy'
65
- | 'expanded'
66
- | 'collapsed'
67
- | 'hasPopup';
68
-
69
59
  declare type A11yValue = {
70
60
  min?: number,
71
61
  max?: number,
@@ -266,25 +256,17 @@ interface A11yAPI {
266
256
  waitForOptions?: WaitForOptions
267
257
  ) => FindAllReturn;
268
258
 
269
- // States
270
- getByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetReturn;
271
- getAllByA11yStates: (matcher: A11yStates | Array<A11yStates>) => GetAllReturn;
272
- queryByA11yStates: (matcher: A11yStates | Array<A11yStates>) => QueryReturn;
273
- queryAllByA11yStates: (
274
- matcher: A11yStates | Array<A11yStates>
275
- ) => QueryAllReturn;
276
-
277
259
  // State
278
- getByA11yState: (matcher: A11yStates) => GetReturn;
279
- getAllByA11yState: (matcher: A11yStates) => GetAllReturn;
280
- queryByA11yState: (matcher: A11yStates) => QueryReturn;
281
- queryAllByA11yState: (matcher: A11yStates) => QueryAllReturn;
260
+ getByA11yState: (matcher: A11yState) => GetReturn;
261
+ getAllByA11yState: (matcher: A11yState) => GetAllReturn;
262
+ queryByA11yState: (matcher: A11yState) => QueryReturn;
263
+ queryAllByA11yState: (matcher: A11yState) => QueryAllReturn;
282
264
  findByA11yState: (
283
- matcher: A11yStates,
265
+ matcher: A11yState,
284
266
  waitForOptions?: WaitForOptions
285
267
  ) => FindReturn;
286
268
  findAllByA11yState: (
287
- matcher: A11yStates,
269
+ matcher: A11yState,
288
270
  waitForOptions?: WaitForOptions
289
271
  ) => FindAllReturn;
290
272