mercredi 12 juin 2019

Testing using Jest, how to expect result to be an array of Components

The code of my test is as follows:


it('makes sure the list items are populated', () => {
    var view = ReactTestUtils.renderIntoDocument(<Sidebar />)
    var result = view.populateLi();
    expect(result).toBe(Array);
});

The result is supposed to be an array of Components called ListItem.

Expected: [Function Array]
Received: [<ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />, <ListItem … />]

How do I write a test to match the Received scenario.

Aucun commentaire:

Enregistrer un commentaire