expect(received).toHaveLength(expected)
Matcher error: received value must have a length property whose value must be a number
Received has value: undefined
8 | })
9 | test('posts', () => {
> 10 | expect(data.posts).toHaveLength(3)
| ^
11 | })
12 | })
13 |
at Object.toHaveLength (exercises/modules/node/test.js:10:24)
● api › getUserById
TypeError: Cannot read property 'find' of undefined
4 | // simulate API call
5 | setTimeout(() => {
> 6 | const user = data.users.find(user => user.id === id)
| ^
7 | cb(user)
8 | }, 150)
9 | }
at find (exercises/modules/node/api.js:6:29)
at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:671:19)
● api › getUserById
expect.assertions(1)
Expected one assertion to be called but received zero assertion calls.
14 | describe('api', () => {
15 | test('getUserById', done => {
> 16 | expect.assertions(1)
| ^
17 | api.getUserById(1, user => {
18 | expect(user.id).toBe(1)
19 | done()
at Object.assertions (exercises/modules/node/test.js:16:12)
I am at fixing modules and I followed the same and even tried to replace it with the solution but it did not work.
data › users
must be a number
● data › posts
● api › getUserById
● api › getUserById
● api › getPostsForUser
● app › showPostsForCurrentUser
● app › showUserProfile
Test Suites: 2 failed, 2 total Tests: 6 failed, 6 total Snapshots: 0 total Time: 1.813s, estimated 2s Ran all test suites.