Skip to content

Commit bd44ca5

Browse files
authored
refactor: format error messages with getErrorMsg()
1 parent 95f0ab9 commit bd44ca5

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

packages/jest-jasmine2/src/jasmine/spy_registry.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,14 @@ export default function SpyRegistry(options: Object) {
136136
this._spyOnProperty = function(obj, propertyName, accessType = 'get') {
137137
if (!obj) {
138138
throw new Error(
139-
'spyOn could not find an object to spy upon for ' + propertyName + '',
139+
getErrorMsg(
140+
'could not find an object to spy upon for ' + propertyName,
141+
),
140142
);
141143
}
142144

143145
if (!propertyName) {
144-
throw new Error('No property name supplied');
146+
throw new Error(getErrorMsg('No property name supplied'));
145147
}
146148

147149
let descriptor;
@@ -152,16 +154,18 @@ export default function SpyRegistry(options: Object) {
152154
}
153155

154156
if (!descriptor) {
155-
throw new Error(propertyName + ' property does not exist');
157+
throw new Error(getErrorMsg(propertyName + ' property does not exist'));
156158
}
157159

158160
if (!descriptor.configurable) {
159-
throw new Error(propertyName + ' is not declared configurable');
161+
throw new Error(getErrorMsg(propertyName + ' is not declared configurable'));
160162
}
161163

162164
if (!descriptor[accessType]) {
163165
throw new Error(
164-
'Property ' + propertyName + ' does not have access type ' + accessType,
166+
getErrorMsg(
167+
'Property ' + propertyName + ' does not have access type ' + accessType,
168+
)
165169
);
166170
}
167171

0 commit comments

Comments
 (0)