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

Write unit tests #4

Open
amitguptagwl opened this Issue Oct 5, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@amitguptagwl
Member

amitguptagwl commented Oct 5, 2018

Following cases are tested manually. Need to write unit tests for auto-testing.

Scenarios
auto-create: on

  • [DONE] Cookies are sent to the client
  • Client can send the session-id to the server either in header or cookies
  • Cookies are not created for all the routes but selected : not implemented yet
  • [DONE] When user makes request without cookies : create new
  • [DONE] When user makes request with expired cookies : create new
  • [DONE] When user makes request with about to expire cookies : renew
  • [DONE] When user makes request with invalid session-id : create new

auto-create: off

  • [DONE] When user makes request with invalid session-id : error
  • [DONE] When user makes request for secure page without cookies : redirect to login page
  • [DONE] When user makes request for secure page with cookies : do nothing
  • [DONE] When user makes request for secure page with expired cookies : redirect to login page
  • [DONE] When user makes request for secure page with about to expire cookies : renew cookies

check session_test.js for more detail.

@msarfrazanwar

This comment has been minimized.

Show comment
Hide comment
@msarfrazanwar

msarfrazanwar Oct 5, 2018

Can you link any resource from where I can learn how to do this ?

msarfrazanwar commented Oct 5, 2018

Can you link any resource from where I can learn how to do this ?

@amitguptagwl

This comment has been minimized.

Show comment
Hide comment
@amitguptagwl

amitguptagwl Oct 6, 2018

Member

You can probably use mocha or jasmine framework to write unit tests. You'll need some library to make HTTP calls. You may use chai & chai-http for this purpose. You may find other good alternatives too but please discuss your tech stack before starting.

Have a look at session_test.js for the sample test. It sets up the server and starts it. Then there is some commented code written for jasmine to test the application. There is some code in chai and chai-http which is used to make a call to the server.

Instead of running the server, you can just test all the files in src folder for their functionality (pure unit tests).

Here are some tutorials which I found using google;

All the best

Member

amitguptagwl commented Oct 6, 2018

You can probably use mocha or jasmine framework to write unit tests. You'll need some library to make HTTP calls. You may use chai & chai-http for this purpose. You may find other good alternatives too but please discuss your tech stack before starting.

Have a look at session_test.js for the sample test. It sets up the server and starts it. Then there is some commented code written for jasmine to test the application. There is some code in chai and chai-http which is used to make a call to the server.

Instead of running the server, you can just test all the files in src folder for their functionality (pure unit tests).

Here are some tutorials which I found using google;

All the best

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment