File tree Expand file tree Collapse file tree 5 files changed +16
-13
lines changed Expand file tree Collapse file tree 5 files changed +16
-13
lines changed Original file line number Diff line number Diff line change 22
33const assert = require ( 'assert' ) ;
44const Parse = require ( '../../node' ) ;
5- const { randomUUID : uuidv4 } = require ( 'crypto' ) ;
5+ const uuidv4 = require ( '../../lib/node/uuid' ) . default ;
66const { twitterAuthData } = require ( './helper' ) ;
77
88class CustomUser extends Parse . User {
Original file line number Diff line number Diff line change 3333 "dependencies" : {
3434 "@babel/runtime-corejs3" : " 7.28.4" ,
3535 "react-native-crypto-js" : " 1.0.0" ,
36- "uuid" : " 13.0.0" ,
3736 "ws" : " 8.18.3"
3837 },
3938 "devDependencies" : {
136135 ".*" : " ./babel-jest.js"
137136 },
138137 "transformIgnorePatterns" : [
139- " /node_modules/(?!uuid)/" ,
140138 " package.json"
141139 ],
142140 "testEnvironment" : " jsdom"
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ jest.dontMock('../EventEmitter');
77jest . dontMock ( '../Parse' ) ;
88jest . dontMock ( '../RESTController' ) ;
99jest . dontMock ( '../Storage' ) ;
10+ jest . dontMock ( '../uuid' ) ;
1011jest . dontMock ( 'crypto-js/aes' ) ;
1112jest . setMock ( '../EventuallyQueue' , { poll : jest . fn ( ) } ) ;
1213
@@ -151,4 +152,13 @@ describe('Browser', () => {
151152 }
152153 expect ( called ) . toBe ( true ) ;
153154 } ) ;
155+
156+ it ( 'load uuid module' , ( ) => {
157+ const uuidv4 = require ( '../uuid' ) . default ;
158+ const uuid1 = uuidv4 ( ) ;
159+ const uuid2 = uuidv4 ( ) ;
160+ expect ( uuid1 ) . toMatch ( / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - 4 [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i) ;
161+ expect ( uuid2 ) . toMatch ( / ^ [ 0 - 9 a - f ] { 8 } - [ 0 - 9 a - f ] { 4 } - 4 [ 0 - 9 a - f ] { 3 } - [ 8 9 a b ] [ 0 - 9 a - f ] { 3 } - [ 0 - 9 a - f ] { 12 } $ / i) ;
162+ expect ( uuid1 ) . not . toEqual ( uuid2 ) ;
163+ } ) ;
154164} ) ;
Original file line number Diff line number Diff line change @@ -20,10 +20,6 @@ const mockWeChat = require('./test_helpers/mockWeChat');
2020
2121global . wx = mockWeChat ;
2222
23- jest . mock ( 'uuid' , ( ) => {
24- return ( ) => 0 ;
25- } ) ;
26-
2723describe ( 'WeChat' , ( ) => {
2824 beforeEach ( ( ) => {
2925 process . env . PARSE_BUILD = 'weapp' ;
Original file line number Diff line number Diff line change @@ -14,13 +14,12 @@ if (process.env.PARSE_BUILD === 'weapp') {
1414 s [ 8 ] = s [ 13 ] = s [ 18 ] = s [ 23 ] = '-' ;
1515 return s . join ( '' ) ;
1616 } ;
17- } else if ( process . env . PARSE_BUILD === 'node' || process . env . PARSE_BUILD === 'react-native' ) {
18- // Use Node.js built-in crypto.randomUUID() for Node and React Native builds
19- // React Native tests run in Node.js environment, and uuid v13 is ESM-only
20- uuid = require ( 'crypto' ) . randomUUID ;
17+ } else if ( process . env . PARSE_BUILD === 'browser' ) {
18+ // Use native crypto.randomUUID() from the Web Crypto API in browsers
19+ uuid = ( ) => globalThis . crypto . randomUUID ( ) ;
2120} else {
22- // Use uuid package for browser builds
23- uuid = require ( 'uuid ' ) . v4 ;
21+ // Use Node.js crypto.randomUUID() for Node and React Native builds
22+ uuid = require ( 'crypto ' ) . randomUUID ;
2423}
2524
2625export default uuid ;
You can’t perform that action at this time.
0 commit comments