Skip to content

Conversation

FranckLecuyer
Copy link
Contributor

No description provided.

Signed-off-by: Franck LECUYER <[email protected]>
@FranckLecuyer FranckLecuyer force-pushed the upgrade_lib_uuid_to_13.0.0 branch from df43d16 to bbceb18 Compare September 15, 2025 14:20
Signed-off-by: Franck LECUYER <[email protected]>
@Tristan-WorkGH
Copy link
Contributor

Oh I see. The CI report that tests failed with

ReferenceError: /home/runner/work/commons-ui/commons-ui/src/components/notifications/test/NotificationsProvider.test.tsx: The module factory of jest.mock() is not allowed to reference any out-of-scope variables.
Invalid variable access: NIL_UUID
Allowed objects: AbortController, AbortSignal, AggregateError, Array, ArrayBuffer, Atomics, BigInt, BigInt64Array, BigUint64Array, Blob, Boolean, BroadcastChannel, Buffer, ByteLengthQueuingStrategy, CompressionStream, CountQueuingStrategy, Crypto, CryptoKey, CustomEvent, DOMException, DataView, Date, DecompressionStream, Error, EvalError, Event, EventTarget, File, FinalizationRegistry, Float32Array, Float64Array, FormData, Function, Generator, GeneratorFunction, Headers, Infinity, Int16Array, Int32Array, Int8Array, InternalError, Intl, Iterator, JSON, Map, Math, MessageChannel, MessageEvent, MessagePort, NaN, Navigator, Number, Object, Performance, PerformanceEntry, PerformanceMark, PerformanceMeasure, PerformanceObserver, PerformanceObserverEntryList, PerformanceResourceTiming, Promise, Proxy, RangeError, ReadableByteStreamController, ReadableStream, ReadableStreamBYOBReader, ReadableStreamBYOBRequest, ReadableStreamDefaultController, ReadableStreamDefaultReader, ReferenceError, Reflect, RegExp, Request, Response, Set, SharedArrayBuffer, String, SubtleCrypto, Symbol, SyntaxError, TextDecoder, TextDecoderStream, TextEncoder, TextEncoderStream, TransformStream, TransformStreamDefaultController, TypeError, URIError, URL, URLSearchParams, Uint16Array, Uint32Array, Uint8Array, Uint8ClampedArray, WeakMap, WeakRef, WeakSet, WebAssembly, WebSocket, WritableStream, WritableStreamDefaultController, WritableStreamDefaultWriter, __dirname, __filename, arguments, atob, btoa, clearImmediate, clearInterval, clearTimeout, console, crypto, decodeURI, decodeURIComponent, encodeURI, encodeURIComponent, escape, eval, expect, exports, fetch, global, globalThis, isFinite, isNaN, jest, module, navigator, parseFloat, parseInt, performance, process, queueMicrotask, require, setImmediate, setInterval, setTimeout, structuredClone, 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.

     14 |
     15 | jest.mock('reconnecting-websocket');
   > 16 | jest.mock('uuid', () => ({ v4: () => NIL_UUID }));
        |                                      ^^^^^^^^

After searching quickly, it seems the only ways is to

  • import * as uuid from 'uuid';
    jest.spyOn(uuid, 'v4').mockReturnValue(uuid.NIL); // no factory, no hoisting issue
  • jest.mock('uuid', () => ({ v4: () => '00000000-0000-0000-0000-000000000000' }));

So yeah my previous review was not correct.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants