FrontendMasters / intro-node-js

[Course] Code for Introduction to Node.js
https://frontendmasters.com/courses/node-js/
372 stars 901 forks source link

Trying to follow along #17

Open venkateshreddypala opened 5 years ago

venkateshreddypala commented 5 years ago

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

expect(received).toHaveLength(expected)

Matcher error: received value must have a length property whose value 

must be a number

Received has value: undefined

   5 | describe('data', () => {
   6 |   test('users',  () => {
>  7 |     expect(data.users).toHaveLength(1)
     |                        ^
   8 |   })
   9 |   test('posts', () => {
  10 |     expect(data.posts).toHaveLength(3)

  at Object.toHaveLength (exercises/modules/node/test.js:7:24)

● data › posts

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)

● api › getPostsForUser

TypeError: Cannot read property 'filter' of undefined

  12 |   // simulate API call
  13 |   setTimeout(() => {
> 14 |     const posts = data.posts.filter(post => post.createdBy === userId)
     |                              ^
  15 |     cb(posts)
  16 |   }, 150)
  17 | }

  at filter (exercises/modules/node/api.js:14:30)
  at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:671:19)

● app › showPostsForCurrentUser

TypeError: Cannot read property 'filter' of undefined

  12 |   // simulate API call
  13 |   setTimeout(() => {
> 14 |     const posts = data.posts.filter(post => post.createdBy === userId)
     |                              ^
  15 |     cb(posts)
  16 |   }, 150)
  17 | }

  at filter (exercises/modules/node/api.js:14:30)
  at Timeout.callback [as _onTimeout] (node_modules/jsdom/lib/jsdom/browser/Window.js:671:19)

● app › showUserProfile

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)

Test Suites: 2 failed, 2 total Tests: 6 failed, 6 total Snapshots: 0 total Time: 1.813s, estimated 2s Ran all test suites.