Commit e1f582a
committed
fix: spyOn should not rely on hasOwnProperty from the spied object
The `spyOn` function uses `hasOwnProperty` from the spied object, but this method can be unavailable,
for example if the object has the `null` prototype, or if it is a proxy that filters some keys.
This arises in Vue 3 projects where the proxies returned by the framework do not expose all methods,
and forces the testing library to manually patch the proxies with `hasOwnProperty` to let Jest do its work
https://github.com/vuejs/vue-test-utils-next/blob/23d3d3e1f4178a87de5023f5255e0623653affdc/src/mount.ts#L493-L495
This commit changes the code to use `Object.prototype.hasOwnProperty` and fixes this issue.1 parent fdc74af commit e1f582a
2 files changed
+16
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1216 | 1216 | | |
1217 | 1217 | | |
1218 | 1218 | | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
1219 | 1231 | | |
1220 | 1232 | | |
1221 | 1233 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
976 | 976 | | |
977 | 977 | | |
978 | 978 | | |
979 | | - | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
980 | 983 | | |
981 | 984 | | |
982 | 985 | | |
| |||
0 commit comments