Skip to content

Commit 083ad17

Browse files
Copilotrenemadsen
andcommitted
Use non-enumerable properties for Jasmine compatibility
- Make 'and' and 'calls' properties non-enumerable to avoid Jest conflicts - Use 'value' instead of 'get' for calls property - Keeps Jest mock structure intact while providing Jasmine API toHaveBeenCalledWith still has issues that require further investigation. Co-authored-by: renemadsen <[email protected]>
1 parent 1c84dd4 commit 083ad17

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

eform-client/src/setup-jest.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,13 @@ if (typeof global.expect === 'undefined') {
4747
return mockFn;
4848
}
4949
}),
50-
configurable: true
50+
configurable: true,
51+
enumerable: false // Don't enumerate this property
5152
});
5253

53-
// Add Jasmine-style 'calls' API that doesn't interfere with Jest
54+
// Add Jasmine-style 'calls' API but make it non-enumerable to avoid conflicts
5455
Object.defineProperty(obj[methodName], 'calls', {
55-
get: () => ({
56+
value: {
5657
reset: () => {
5758
mockFn.mockClear();
5859
},
@@ -72,8 +73,10 @@ if (typeof global.expect === 'undefined') {
7273
argsFor: (index: number) => {
7374
return mockFn.mock.calls[index];
7475
}
75-
}),
76-
configurable: true
76+
},
77+
writable: true,
78+
configurable: true,
79+
enumerable: false // Don't enumerate this property
7780
});
7881
});
7982
return obj;
@@ -97,12 +100,13 @@ if (typeof global.expect === 'undefined') {
97100
return spy;
98101
}
99102
}),
100-
configurable: true
103+
configurable: true,
104+
enumerable: false
101105
});
102106

103107
// Add Jasmine-style 'calls' API
104108
Object.defineProperty(spy, 'calls', {
105-
get: () => ({
109+
value: {
106110
reset: () => {
107111
spy.mockClear();
108112
},
@@ -122,8 +126,10 @@ if (typeof global.expect === 'undefined') {
122126
argsFor: (index: number) => {
123127
return spy.mock.calls[index];
124128
}
125-
}),
126-
configurable: true
129+
},
130+
writable: true,
131+
configurable: true,
132+
enumerable: false
127133
});
128134

129135
return spy;

0 commit comments

Comments
 (0)