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

Add testing #19

Closed
3 tasks done
abbycabs opened this issue May 20, 2015 · 18 comments
Closed
3 tasks done

Add testing #19

abbycabs opened this issue May 20, 2015 · 18 comments

Comments

@abbycabs
Copy link
Member

Use Mocha!

@abbycabs
Copy link
Member Author

@audy may look into this during the sprint

@abbycabs
Copy link
Member Author

Mocha: http://mochajs.org/

@abbycabs abbycabs mentioned this issue May 22, 2015
@audy
Copy link
Member

audy commented May 22, 2015

We'll also need to mock HTTP responses somehow. Is there a node.js thing for that? Google-first-hit says http://sinonjs.org/.

@audy
Copy link
Member

audy commented May 22, 2015

@aid29 I added Mocha over on here https://github.com/audy/PaperBadger/tree/add-test-framework. It's only a few lines of code so I won't be heartbroken if you don't use it.

@ibjhb
Copy link

ibjhb commented Jun 3, 2015

If you need to mock HTTP/API responses, you might want to check out:
https://github.com/typicode/json-server

@abbycabs
Copy link
Member Author

abbycabs commented Jun 3, 2015

Thanks @ibjhb -- helpful :)

@audy
Copy link
Member

audy commented Jun 3, 2015

@aid29 I'm working on this but the internet says there are a thousand different ways.

Frequently, I see people running the server and sending it HTTP requests with superagent. This is different from what I'm used to with Ruby (you test the HTTP methods without running the actual HTTP server). Would you recommend this approach?

@aid29
Copy link
Contributor

aid29 commented Jun 4, 2015

Hi @audy , I think we can start by having some integration tests for testing the endpoints with real http server (maybe ask @acabunoc some golden data), then have some unit tests for the logic calling the Mozzila Badge API which dependent on #26

@audy
Copy link
Member

audy commented Jun 4, 2015

I need to do some restructuring so I can unit test methods inside of src/app.js.

This is my idea:

  • src/routes.js - express.js routing
  • src/helpers.js - misc functions used throughout the app like emailFromORCID for example.

I need to rewrite helpers.js as a module.

instead of

module.exports = function(config) {
  function foo(bar) {
    return 'baz';
  };
};

I would need to write

module.exports = function(config) {
  foo: function(bar) {
    return "baz";
  };
};

So that I am able to access these functions from my tests. Or is there another way?

How about I send a PR for the basic testing skeleton w/o any tests, then work on what I have just proposed in another branch, then start adding actual tests after the first two things are done?

abbycabs added a commit that referenced this issue Jun 4, 2015
audy added a commit to audy/PaperBadger that referenced this issue Jun 5, 2015
audy added a commit that referenced this issue Jun 5, 2015
added basic API testing with supertest for #19
@abbycabs
Copy link
Member Author

abbycabs commented Jun 5, 2015

@JJ - writing tests with @audy might be a good place to jump in :)

@audy
Copy link
Member

audy commented Jun 5, 2015

Good place for "golden" data https://github.com/mozilla/badgekit-api-client/tree/master/docs

@abbycabs
Copy link
Member Author

abbycabs commented Jun 5, 2015

@abbycabs
Copy link
Member Author

abbycabs commented Jun 5, 2015

@aid29
Copy link
Contributor

aid29 commented Jun 10, 2015

@audy Nice job for the setup and init tests ;)
Currently pbm is the npm script "test" is failed because Cannot find module 'supertest'. What is the plan for that? Can I do the fix?

@abbycabs
Copy link
Member Author

Hey @aid29! Did you run npm install? There are a few new modules :)

@aid29
Copy link
Contributor

aid29 commented Jun 10, 2015

I forgot it :p

@abbycabs
Copy link
Member Author

It happens :)

@aid29
Copy link
Contributor

aid29 commented Jul 22, 2015

@acabunoc As #25 #26 are both close, can we close this one as well?

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

No branches or pull requests

4 participants