Comments (13)
Still broken on 0.2.1
. 😭
from ionic-react-test-utils.
Thanks for the report and apologies for the delay. This issue has been fixed in #44, and the fix will be available in the next release of Ionic React Test Utils.
Please note that we removed the IonDatetime mock in this patch. In Ionic v5, IonDatetime was rendered as an overlay which required us to use a mock (similar to what we do for IonModal, IonAlert, etc). In Ionic v6, IonDatetime is rendered inline so the mock is not needed. However, developers can continue to test IonDatetime in their apps.
from ionic-react-test-utils.
This seems to have been resolved in
0.3.0
. If others can confirm, I think this can be closed.
Still exists in 0.3.0
from ionic-react-test-utils.
Same problem here, I was in 0.1.1, I downgraded to version 0.0.3 and it worked.
from ionic-react-test-utils.
I had this problem on version 0.0.3. Upgraded to 0.2.0 and still didn't work. Inside mockIonicReact.js, Jest can't use the mockController unless the variable to which it is assigned also begins with the word "mock"
See
https://jestjs.io/docs/es6-class-mocks#calling-jestmock-with-the-module-factory-parameter
https://stackoverflow.com/questions/60665358/not-able-to-access-variables-in-jest-mock-function
from ionic-react-test-utils.
I had the same problem with the latest versions.
Downgrading to 0.0.3
worked for me.
from ionic-react-test-utils.
Just noticed version 0.2.0
was released a couple of months ago. Upgraded to that to see if anything changed, but unfortunately the issue still persists on that version. 😢
from ionic-react-test-utils.
This seems to have been resolved in 0.3.0
. If others can confirm, I think this can be closed.
from ionic-react-test-utils.
Still exists in
0.3.0
@tekno0ryder Weird, I upgraded and everything is working fine for my project now. 😕
from ionic-react-test-utils.
Still exists in
0.3.0
@tekno0ryder Weird, I upgraded and everything is working fine for my project now. 😕
@zrev2220 I just wanted to test <IonInput/>
events, so I ended up importing only ionFireEvent util and it's worked
import { ionFireEvent } from "@ionic/react-test-utils/dist/ionFireEvent";
from ionic-react-test-utils.
Still happening on 0.3.1
:
ReferenceError: .../node_modules/@ionic/react-test-utils/dist/mocks/mockIonicReact.js: The module factory of `jest.mock()` is not allowed to reference any out-of-scope variables.
Invalid variable access: react_1
Allowed objects: AbortController, AbortSignal, AggregateError, Array, ArrayBuffer, Atomics, BigInt, BigInt64Array, BigUint64Array, Boolean, Buffer, DataView, Date, Error, EvalError, Event, EventTarget, FinalizationRegistry, Float32Array, Float64Array, Function, Generator, GeneratorFunction, Infinity, Int16Array, Int32Array, Int8Array, InternalError, Intl, JSON, Map, Math, MessageChannel, MessageEvent, MessagePort, NaN, Number, Object, Promise, Proxy, RangeError, ReferenceError, Reflect, RegExp, Set, SharedArrayBuffer, String, Symbol, SyntaxError, TextDecoder, TextEncoder, TypeError, URIError, URL, URLSearchParams, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, WeakMap, WeakRef, WeakSet, WebAssembly, arguments, atob, btoa, clearImmediate, clearInterval, clearTimeout, console, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, eval, expect, global, globalThis, isFinite, isNaN, jest, parseFloat, parseInt, performance, process, queueMicrotask, require, setImmediate, setInterval, setTimeout, undefined, unescape.
Note: This is a precaution to guard against uninitialized mock variables. If it is ensured that the mock is required lazily, variable names prefixed with `mock` (case insensitive) are permitted.
8 | jest.mock('@ionic/react', () => {
9 | const rest = jest.requireActual('@ionic/react');
> 10 | return Object.assign(Object.assign({}, rest), { IonActionSheet: mockController_1.mockController, IonAlert: mockController_1.mockController, IonCheckbox: mockIonCheckbox_1.mockIonCheckbox, IonDatetime: react_1.IonInput, IonLoading: mockController_1.mockController, IonPicker: mockController_1.mockController, IonPopover: mockController_1.mockController, IonToast: mockController_1.mockController, IonModal: mockController_1.mockController, IonToggle: mockIonCheckbox_1.mockIonCheckbox, useIonPicker: useIonPicker_mock_1.mockUseIonPicker });
| ^^^^^^^
11 | });
12 | }
13 | exports.mockIonicReact = mockIonicReact;
at File.buildCodeFrameError (../../node_modules/@babel/core/lib/transformation/file/file.js:249:12)
at NodePath.buildCodeFrameError (../../node_modules/@babel/traverse/lib/path/index.js:139:21)
at newFn (../../node_modules/@babel/traverse/lib/visitors.js:177:21)
at NodePath._call (../../node_modules/@babel/traverse/lib/path/context.js:53:20)
at NodePath.call (../../node_modules/@babel/traverse/lib/path/context.js:40:17)
at NodePath.visit (../../node_modules/@babel/traverse/lib/path/context.js:100:31)
at TraversalContext.visitQueue (../../node_modules/@babel/traverse/lib/context.js:103:16)
Isn't something with the configuration wise ?
from ionic-react-test-utils.
Until this issue is fixed, feel free to use https://www.npmjs.com/package/@ananto/react-test-utils as a drop in replacement.
from ionic-react-test-utils.
This fix has been released as part of v0.4.0.
npm install @ionic/react-test-utils@latest
from ionic-react-test-utils.
Related Issues (15)
- React does not recognize the `backdropDismiss` prop HOT 6
- ionChange not firing correctly on IonRange
- `mockIonCheckbox` throws an error when `onIonFocus` or `onIonBlur` is provided HOT 2
- bug: onDidPresent not handled by MockController HOT 1
- IonicTabs need mocking
- Imposibility of testing IonInput HOT 1
- ionChange doesn't work on searchBar
- bug: ionic-react-test-utils not compatible with vitest HOT 2
- mockIonCheckbox throws an unhelpful error when no onIonChange is defined. HOT 1
- Is this package using older RTL that causes previous unit test's render leaking into next
- Using with Vitest gives ReferenceError: jest is not defined HOT 3
- IonAlert and IonModal should toggle isOpen after clicking on any button (handler callback)
- onWillDissmiss() is not called in MockController HOT 1
- feature: export mock controller to allow cherry picking of mocking ionic components
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ionic-react-test-utils.