1

I'm trying to grasp the basics of Jasmine (and BDD/TDD I guess). The examples I have seen does not resemble any realistic scenario of a web application, and have a hard time relating to it.

Are Jasmine tests done aside (separately) from working on the JavaScript that will be deployed? Manually copying tested/validated code.. Or does Jasmine compile to standard JS used for production?

Cheers

gorn
  • 8,097
  • 5
  • 37
  • 44

1 Answers1

1

Jasmine is a framework for testing JavaScript code. Just like testing Ruby on Rails code, the tests don't become part of the production code. They are in the same repo and are run but they aren't minified into project.js or whatever your build process is. As part of your test run process, you can do headless tests using PhantomJS (headless webkit) and have it run on your CI server and so forth just like any other test.

I have worked on a bunch of projects this way. There has been a trend of seeing JavaScript has an enhancement layer that doesn't really need to be tested but today JavaScript is so much more. It is critical to test it if your application needs to work.

Cymen
  • 14,079
  • 4
  • 52
  • 72
  • What is the relationship between Jasmine tests and the live JS? Manual copying back and forth (what is formalized and what isn't)? Apologies for the series of stupid questions :) Can't seem to grasp how the test process goes. – gorn Feb 22 '13 at 08:42
  • I think what you are asking is how does TDD work, right? That is a big question that is hard to answer here. But one thing to consider is that code written using TDD in my experience looks much different than without TDD. At first that seems wrong but it isn't -- it will force you to write code more carefully and consider dependencies. Perhaps looking for some introduction videos would help? Look for ones where they always write the test (and verify it fails) before writing the code. – Cymen Feb 22 '13 at 15:29
  • @gorn This post might be useful: [Good resource to learn BDD, TDD (ruby , C#, javascript)](http://stackoverflow.com/questions/1186434/good-resource-to-learn-bdd-tdd-ruby-c-javascript) – Cymen Feb 25 '13 at 15:04