Reputation: 1701
Jest expects the expected Cell
property value to be [Function anonymous]
.
What is correct syntax for that?
() => {}
seems to be [Function Cell]
thus test fails.
const expected =
[{ Cell: () => {}, Header: '', accessor: () => {}, disableSortBy: true, id: 18, width: 50 }];
expect(result).toBe(expected);
Console:
$ jest test
----
- Expected - 1
+ Received + 1
@@ -1,8 +1,8 @@
Array [
Object {
- "Cell": [Function Cell],
+ "Cell": [Function anonymous],
"Header": "",
"accessor": [Function accessor],
"disableSortBy": true,
"id": 18,
"width": 50,
Upvotes: 8
Views: 12294
Reputation: 3461
You need to tell that it expects array and then objects on it. Each object needs to be specified its type or value
Try something like this
const expected = expect.arrayContaining([
expect.objectContaining({
Cell: expect.any(Function),
Header: expect.any(String),
accessor: expect.any(Function),
disableSortBy: expect.any(Boolean),
/*...........so..on............*/
})
]);
expect(result).toEqual(expected);
Upvotes: 8