Coder Social home page Coder Social logo

Comments (13)

zrev2220 avatar zrev2220 commented on July 21, 2024 2

Still broken on 0.2.1. 😭

from ionic-react-test-utils.

liamdebeasi avatar liamdebeasi commented on July 21, 2024 2

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.

tekno0ryder avatar tekno0ryder commented on July 21, 2024 1

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.

Adzerty avatar Adzerty commented on July 21, 2024

Same problem here, I was in 0.1.1, I downgraded to version 0.0.3 and it worked.

from ionic-react-test-utils.

mkmatheson avatar mkmatheson commented on July 21, 2024

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.

matheusbozetti avatar matheusbozetti commented on July 21, 2024

I had the same problem with the latest versions.

Downgrading to 0.0.3 worked for me.

from ionic-react-test-utils.

zrev2220 avatar zrev2220 commented on July 21, 2024

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.

zrev2220 avatar zrev2220 commented on July 21, 2024

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.

zrev2220 avatar zrev2220 commented on July 21, 2024

Still exists in 0.3.0

@tekno0ryder Weird, I upgraded and everything is working fine for my project now. 😕

from ionic-react-test-utils.

tekno0ryder avatar tekno0ryder commented on July 21, 2024

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.

fxsalazar avatar fxsalazar commented on July 21, 2024

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.

anantoghosh avatar anantoghosh commented on July 21, 2024

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.

liamdebeasi avatar liamdebeasi commented on July 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.