Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Add unit testing framework for JS #151

Closed
mduan opened this issue Apr 14, 2014 · 8 comments
Closed

Add unit testing framework for JS #151

mduan opened this issue Apr 14, 2014 · 8 comments

Comments

@mduan
Copy link
Contributor

mduan commented Apr 14, 2014

We don't currently have anything for unit testing our JavaScript code. Having this would be useful for testing things like the transcript and schedule parsing logic (see #105).

I don't really have any strong feeling for any specific unit testing framework, but one I have encountered in the past in Jasmine.

@JGulbronson
Copy link
Member

Jasmine looks good, I'll take a look at it

@divad12
Copy link
Member

divad12 commented Apr 14, 2014

I believe @phleet likes http://visionmedia.github.io/mocha/. Any thoughts, Jamie?

@jlfwong
Copy link
Member

jlfwong commented Apr 14, 2014

Currently favored setup:

  • Mocha for test runner, using the BDD syntax.
  • chaijs for assertions, using the expect() syntax.
  • sinonjs for mocking (though I need to use this very infrequently, and when I do it's usually to mock ajax requests)

The hard thing for JavaScript testing is keeping the test in good working order. This is facilitated in our python codebase by making make test a deploy blocker (you cannot deploy if the tests are failing). It turns out that making client-side JavaScript tests report back to the console with their success or failure is a huge pain (this was what I spent 2 months at two different companies doing). Thankfully we already have a module system (RequireJS) which makes part of this challenge go away.

The most consistently applied tool I've seen for this is Karma, though I haven't used it much personally. I ended up using either PhantomJS or backgrounded Google Chrome windows in the past for doing this kind of thing, and rolling my own system to support it.

@JGulbronson
Copy link
Member

So if I'm correct right now we're looking to test the transcript and schedule parsers. I'll check out Mocha and chaijs, as well as the current parser for transcripts and see if I can come up with some tests we can run.

Is there any other Javascript code we should be testing aside from the parser?

@jlfwong
Copy link
Member

jlfwong commented Apr 14, 2014

Tons, but don't worry about that for now :)

@JGulbronson
Copy link
Member

Haha sounds good, looks like getting the tests for this will take me a little bit anyway, especially given the 3 exams in 3 days I have starting tomorrow 👎 Good study break though. I'll start with the transcript parser since that code seems for manageable right now.

@divad12
Copy link
Member

divad12 commented Apr 14, 2014

Oh man. Good luck on the exams!

@JGulbronson
Copy link
Member

👍 Thanks David, looking forward to Wednesday night trust me

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

No branches or pull requests

4 participants