@@ -1151,7 +1151,7 @@ describe('src/cy/commands/assertions', () => {
1151
1151
} )
1152
1152
} )
1153
1153
1154
- context ( 'format quotation marks ', ( ) => {
1154
+ describe ( 'message formatting ', ( ) => {
1155
1155
const expectMarkdown = ( test , message , done ) => {
1156
1156
cy . then ( ( ) => {
1157
1157
test ( )
@@ -1168,70 +1168,83 @@ describe('src/cy/commands/assertions', () => {
1168
1168
} )
1169
1169
}
1170
1170
1171
- it ( 'preserves quotation marks in number strings' , ( done ) => {
1172
- expectMarkdown ( ( ) => {
1173
- try {
1174
- expect ( 25 ) . to . eq ( '25' )
1175
- } catch ( error ) { } /* eslint-disable-line no-empty */
1176
- } ,
1177
- `expected **25** to equal **'25'**` ,
1178
- done )
1179
- } )
1180
-
1181
- it ( 'preserves quotation marks in empty string' , ( done ) => {
1182
- expectMarkdown ( ( ) => {
1183
- try {
1184
- expect ( 42 ) . to . eq ( '' )
1185
- } catch ( error ) { } /* eslint-disable-line no-empty */
1186
- } ,
1187
- `expected **42** to equal **''**` ,
1188
- done )
1189
- } )
1171
+ // https://github.com/cypress-io/cypress/issues/19116
1172
+ it ( 'text with backslashes' , ( done ) => {
1173
+ const text = '"<OE_D]dQ\\'
1190
1174
1191
- it ( 'preserves quotation marks if escaped' , ( done ) => {
1192
1175
expectMarkdown (
1193
- ( ) => expect ( `\'cypress\'` ) . to . eq ( `\'cypress\'` ) ,
1194
- // ****'cypress'**** -> ** for emphasizing result string + ** for emphasizing the entire result.
1195
- `expected **'cypress'** to equal ****'cypress'****` ,
1176
+ ( ) => expect ( text ) . to . equal ( text ) ,
1177
+ `expected **"<OE_D]dQ\\\\** to equal **"<OE_D]dQ\\\\**` ,
1196
1178
done ,
1197
1179
)
1198
1180
} )
1199
1181
1200
- it ( 'removes quotation marks in DOM elements ', ( done ) => {
1201
- expectMarkdown (
1202
- ( ) => {
1203
- cy . get ( 'body' ) . then ( ( $body ) => {
1204
- expect ( $body ) . to . contain ( 'div ')
1205
- } )
1182
+ describe ( 'messages with quotation marks', ( ) => {
1183
+ it ( 'preserves quotation marks in number strings' , ( done ) => {
1184
+ expectMarkdown ( ( ) => {
1185
+ try {
1186
+ expect ( 25 ) . to . eq ( '25 ')
1187
+ } catch ( error ) { } /* eslint-disable-line no-empty */
1206
1188
} ,
1207
- `expected **<body>** to contain **div**` ,
1208
- done ,
1209
- )
1210
- } )
1189
+ `expected **25** to equal **'25'**` ,
1190
+ done )
1191
+ } )
1211
1192
1212
- it ( 'removes quotation marks in strings' , ( done ) => {
1213
- expectMarkdown ( ( ) => expect ( 'cypress' ) . to . eq ( 'cypress' ) , `expected **cypress** to equal **cypress**` , done )
1214
- } )
1193
+ it ( 'preserves quotation marks in empty string' , ( done ) => {
1194
+ expectMarkdown ( ( ) => {
1195
+ try {
1196
+ expect ( 42 ) . to . eq ( '' )
1197
+ } catch ( error ) { } /* eslint-disable-line no-empty */
1198
+ } ,
1199
+ `expected **42** to equal **''**` ,
1200
+ done )
1201
+ } )
1215
1202
1216
- it ( 'removes quotation marks in objects' , ( done ) => {
1217
- expectMarkdown (
1218
- ( ) => expect ( { foo : 'bar' } ) . to . deep . eq ( { foo : 'bar' } ) ,
1219
- `expected **{ foo: bar }** to deeply equal **{ foo: bar }**` ,
1220
- done ,
1221
- )
1222
- } )
1203
+ it ( 'preserves quotation marks if escaped' , ( done ) => {
1204
+ expectMarkdown (
1205
+ ( ) => expect ( `\'cypress\'` ) . to . eq ( `\'cypress\'` ) ,
1206
+ // ****'cypress'**** -> ** for emphasizing result string + ** for emphasizing the entire result.
1207
+ `expected **'cypress'** to equal ****'cypress'****` ,
1208
+ done ,
1209
+ )
1210
+ } )
1223
1211
1224
- it ( 'formats keys properly for "have.all.keys"' , ( done ) => {
1225
- const person = {
1226
- name : 'Joe' ,
1227
- age : 20 ,
1228
- }
1212
+ it ( 'removes quotation marks in DOM elements' , ( done ) => {
1213
+ expectMarkdown (
1214
+ ( ) => {
1215
+ cy . get ( 'body' ) . then ( ( $body ) => {
1216
+ expect ( $body ) . to . contain ( 'div' )
1217
+ } )
1218
+ } ,
1219
+ `expected **<body>** to contain **div**` ,
1220
+ done ,
1221
+ )
1222
+ } )
1229
1223
1230
- expectMarkdown (
1231
- ( ) => expect ( person ) . to . have . all . keys ( 'name' , 'age' ) ,
1232
- `expected **{ name: Joe, age: 20 }** to have keys **name**, and **age**` ,
1233
- done ,
1234
- )
1224
+ it ( 'removes quotation marks in strings' , ( done ) => {
1225
+ expectMarkdown ( ( ) => expect ( 'cypress' ) . to . eq ( 'cypress' ) , `expected **cypress** to equal **cypress**` , done )
1226
+ } )
1227
+
1228
+ it ( 'removes quotation marks in objects' , ( done ) => {
1229
+ expectMarkdown (
1230
+ ( ) => expect ( { foo : 'bar' } ) . to . deep . eq ( { foo : 'bar' } ) ,
1231
+ `expected **{ foo: bar }** to deeply equal **{ foo: bar }**` ,
1232
+ done ,
1233
+ )
1234
+ } )
1235
+
1236
+ it ( 'formats keys properly for "have.all.keys"' , ( done ) => {
1237
+ const person = {
1238
+ name : 'Joe' ,
1239
+ age : 20 ,
1240
+ }
1241
+
1242
+ expectMarkdown (
1243
+ ( ) => expect ( person ) . to . have . all . keys ( 'name' , 'age' ) ,
1244
+ `expected **{ name: Joe, age: 20 }** to have keys **name**, and **age**` ,
1245
+ done ,
1246
+ )
1247
+ } )
1235
1248
} )
1236
1249
1237
1250
describe ( 'formats strings with spaces' , ( done ) => {
@@ -1269,36 +1282,6 @@ describe('src/cy/commands/assertions', () => {
1269
1282
} )
1270
1283
} )
1271
1284
1272
- // TODO: this suite should be merged with the suite above
1273
- describe ( 'message formatting' , ( ) => {
1274
- const expectMarkdown = ( test , message , done ) => {
1275
- cy . then ( ( ) => {
1276
- test ( )
1277
- } )
1278
-
1279
- cy . on ( 'log:added' , ( attrs , log ) => {
1280
- if ( attrs . name === 'assert' ) {
1281
- cy . removeAllListeners ( 'log:added' )
1282
-
1283
- expect ( log . get ( 'message' ) ) . to . eq ( message )
1284
-
1285
- done ( )
1286
- }
1287
- } )
1288
- }
1289
-
1290
- // https://github.com/cypress-io/cypress/issues/19116
1291
- it ( 'text with backslashes' , ( done ) => {
1292
- const text = '"<OE_D]dQ\\'
1293
-
1294
- expectMarkdown (
1295
- ( ) => expect ( text ) . to . equal ( text ) ,
1296
- `expected **"<OE_D]dQ\\\\** to equal **"<OE_D]dQ\\\\**` ,
1297
- done ,
1298
- )
1299
- } )
1300
- } )
1301
-
1302
1285
context ( 'chai overrides' , ( ) => {
1303
1286
beforeEach ( function ( ) {
1304
1287
this . $body = cy . $$ ( 'body' )
0 commit comments