Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Most of the tests fail #61

Open
mjgs opened this issue Jul 16, 2018 · 3 comments
Open

Most of the tests fail #61

mjgs opened this issue Jul 16, 2018 · 3 comments

Comments

@mjgs
Copy link

mjgs commented Jul 16, 2018

I'm not familiar with newman, so no idea how to debug this, there is just two json files, where is the code?

/tmp $ git clone https://github.com/gothinkster/node-express-realworld-example-app
Cloning into 'node-express-realworld-example-app'...
remote: Counting objects: 250, done.
remote: Total 250 (delta 0), reused 0 (delta 0), pack-reused 250
Receiving objects: 100% (250/250), 127.33 KiB | 149.00 KiB/s, done.
Resolving deltas: 100% (116/116), done.
/tmp $ cd node-express-realworld-example-app/
/tmp/node-express-realworld-example-app $ npm install
npm WARN deprecated [email protected]: Critical security bugs fixed in 2.5.5
npm WARN deprecated [email protected]: Use uuid module instead
npm WARN deprecated [email protected]: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
npm WARN deprecated [email protected]: Please upgrade to 2.2.19 or higher

> [email protected] install /private/tmp/node-express-realworld-example-app/node_modules/fsevents
> node install

[fsevents] Success: "/private/tmp/node-express-realworld-example-app/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" is installed via remote

> [email protected] postinstall /private/tmp/node-express-realworld-example-app/node_modules/nodemon
> node bin/postinstall || exit 0

npm notice created a lockfile as package-lock.json. You should commit this file.
added 653 packages in 31.609s
/tmp/node-express-realworld-example-app $ npm test

> [email protected] test /private/tmp/node-express-realworld-example-app
> newman run ./tests/api-tests.postman.json -e ./tests/env-api-tests.postman.json

newman

Conduit API Tests

❏ Auth
↳ Register
  POST http://localhost:3000/api/users   2⠄ JSONError in test-script

↳ Login
  POST http://localhost:3000/api/users/login   4⠄ JSONError in test-script

↳ Login and Remember Token
  POST http://localhost:3000/api/users/login   6⠄ JSONError in test-script

↳ Current User
  GET http://localhost:3000/api/user   8⠄ JSONError in test-script

↳ Update User
  PUT http://localhost:3000/api/user  10⠄ JSONError in test-script

❏ Articles with authentication
↳ Feed
  GET http://localhost:3000/api/articles/feed  12. Response code is 200 OK

↳ All Articles
  GET http://localhost:3000/api/articles  14. Response code is 200 OK

↳ All Articles with auth
  GET http://localhost:3000/api/articles  16. Response code is 200 OK

↳ Articles by Author
  GET http://localhost:3000/api/articles?author=johnjacob  18. Response code is 200 OK

↳ Articles by Author with auth
  GET http://localhost:3000/api/articles?author=johnjacob  20. Response code is 200 OK

↳ Articles Favorited by Username
  GET http://localhost:3000/api/articles?favorited=jane  22. Response code is 200 OK

↳ Articles Favorited by Username with auth
  GET http://localhost:3000/api/articles?favorited=jane  24. Response code is 200 OK

↳ Articles by Tag
  GET http://localhost:3000/api/articles?tag=dragons  26. Response code is 200 OK

↳ Create Article
  POST http://localhost:3000/api/articles  28⠄ JSONError in test-script

↳ Single Article by slug
  GET http://localhost:3000/api/articles/{{slug}}  30⠄ JSONError in test-script

↳ Update Article
  PUT http://localhost:3000/api/articles/{{slug}}  32⠄ JSONError in test-script

↳ Favorite Article
  POST http://localhost:3000/api/articles/{{slug}}/favorite  34⠄ JSONError in test-script

↳ Unfavorite Article
  DELETE http://localhost:3000/api/articles/{{slug}}/favorite  36⠄ JSONError in test-script

❏ Articles
↳ All Articles
  GET http://localhost:3000/api/articles  38. Response code is 200 OK

↳ Articles by Author
  GET http://localhost:3000/api/articles?author=johnjacob  40. Response code is 200 OK

↳ Articles Favorited by Username
  GET http://localhost:3000/api/articles?favorited=jane  42. Response code is 200 OK

↳ Articles by Tag
  GET http://localhost:3000/api/articles?tag=dragons  44. Response code is 200 OK

↳ Single Article by slug
  GET http://localhost:3000/api/articles/{{slug}}  46⠄ JSONError in test-script

❏ Comments
↳ All Comments for Article
  GET http://localhost:3000/api/articles/{{slug}}/comments  48. Response code is 200 OK

↳ Create Comment for Article
  POST http://localhost:3000/api/articles/{{slug}}/comments  50⠄ JSONError in test-script

↳ Delete Comment for Article
  DELETE http://localhost:3000/api/articles/{{slug}}/comments/1
❏ Profiles
↳ Profile
  GET http://localhost:3000/api/profiles/johnjacob  53. Response code is 200 OK

↳ Follow Profile
  POST http://localhost:3000/api/profiles/johnjacob/follow  55. Response code is 200 OK

↳ Unfollow Profile
  DELETE http://localhost:3000/api/profiles/johnjacob/follow  57. Response code is 200 OK

❏ Tags
↳ All Tags
  GET http://localhost:3000/api/tags  59. Response code is 200 OK

❏ Cleanup
↳ Delete Article
  DELETE http://localhost:3000/api/articles/{{slug}}
┌─────────────────────────┬──────────┬──────────┐
│                         │ executed │   failed │
├─────────────────────────┼──────────┼──────────┤
│              iterations │        1 │        0 │
├─────────────────────────┼──────────┼──────────┤
│                requests │       31 │       31 │
├─────────────────────────┼──────────┼──────────┤
│            test-scripts │       29 │       12 │
├─────────────────────────┼──────────┼──────────┤
│      prerequest-scripts │        0 │        0 │
├─────────────────────────┼──────────┼──────────┤
│              assertions │       17 │       17 │
├─────────────────────────┴──────────┴──────────┤
│ total run duration: 772ms                     │
├───────────────────────────────────────────────┤
│ total data received: 0B (approx)              │
├───────────────────────────────────────────────┤
│ average response time: 0ms                    │
└───────────────────────────────────────────────┘

   #  failure                    detail

 01.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Auth / Register"

 02.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Auth / Register"

 03.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Auth / Login"

 04.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Auth / Login"

 05.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Auth / Login and Remember Token"

 06.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Auth / Login and Remember Token"

 07.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Auth / Current User"

 08.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Auth / Current User"

 09.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Auth / Update User"

 10.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Auth / Update User"

 11.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Feed"

 12.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Feed"

 13.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / All Articles"

 14.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / All Articles"

 15.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / All Articles with auth"

 16.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / All Articles with auth"

 17.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Articles by Author"

 18.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Articles by Author"

 19.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Articles by Author with auth"

 20.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Articles by Author with auth"

 21.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Articles Favorited by Username"

 22.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Articles Favorited by Username"

 23.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Articles Favorited by Username with auth"

 24.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Articles Favorited by Username with auth"

 25.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Articles by Tag"

 26.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles with authentication / Articles by Tag"

 27.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Create Article"

 28.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles with authentication / Create Article"

 29.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Single Article by slug"

 30.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles with authentication / Single Article by slug"

 31.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Update Article"

 32.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles with authentication / Update Article"

 33.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Favorite Article"

 34.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles with authentication / Favorite Article"

 35.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles with authentication / Unfavorite Article"

 36.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles with authentication / Unfavorite Article"

 37.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles / All Articles"

 38.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles / All Articles"

 39.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles / Articles by Author"

 40.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles / Articles by Author"

 41.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles / Articles Favorited by Username"

 42.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles / Articles Favorited by Username"

 43.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles / Articles by Tag"

 44.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Articles / Articles by Tag"

 45.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Articles / Single Article by slug"

 46.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Articles / Single Article by slug"

 47.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Comments / All Comments for Article"

 48.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Comments / All Comments for Article"

 49.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Comments / Create Comment for Article"

 50.  JSONError                  Unexpected token u in JSON at position 0
                                 at test-script
                                 inside "Comments / Create Comment for Article"

 51.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Comments / Delete Comment for Article"

 52.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Profiles / Profile"

 53.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Profiles / Profile"

 54.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Profiles / Follow Profile"

 55.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Profiles / Follow Profile"

 56.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Profiles / Unfollow Profile"

 57.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Profiles / Unfollow Profile"

 58.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Tags / All Tags"

 59.  AssertionError             Response code is 200 OK
                                 expected false to be truthy
                                 at assertion:0 in test-script
                                 inside "Tags / All Tags"

 60.  Error                      connect ECONNREFUSED 127.0.0.1:3000
                                 at request
                                 inside "Cleanup / Delete Article"
npm ERR! Test failed.  See above for more details.
/tmp/node-express-realworld-example-app $ node -v
v9.2.0
@migliozziz
Copy link

migliozziz commented Aug 17, 2018

You ran the test without starting the application. Be sure to npm run dev before you npm run test. You can find your test files in ./test.

@mjgs
Copy link
Author

mjgs commented Aug 24, 2018

Right, that's better. Might be an idea to have the app start in whatever the newman equivalent of a before hook is. All the tests now pass apart from:

Auth
↳ Register
POST http://localhost:3000/api/users [422 Unprocessable Entity, 358B, 163ms]

  1. Response contains "user" property
  2. User has "email" property
  3. User has "username" property
  4. User has "token" property

I can see the test code in the json file now, how do I run and debug it? Is there some way to extract the code so I can run it in a debugger?

@ftes
Copy link

ftes commented Jan 22, 2019

I suggest closing this issue. The tests run fine if the app is first started. I think that's a fair precondition.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants