vendredi 21 août 2020

Testing that an array of objects contains a certain key using Mocha/Chai

I am trying to write some tests using Mocha and Chai on an array of objects. I want to go through this array and return any objects that contain the error key. I figured this sort of thing would be easy, but I am having a difficult time of it.

 [ 
   { fileName: 'font1.ttc', error: 'font_type_not_supported' },
   { fileName: 'font2.ttf', error: 'parse_failed' },
   { fileName: 'font3.tff' } 
 ]

I've tried things like. expect(testResult).to.have.nested.property('error');

I'm probably missing something simple, does anyone have any suggestions?

Aucun commentaire:

Enregistrer un commentaire