tdd - Test driven development for a JavaScript library - Stack Overflow

At the moment I'm working on a JS library for a webservice, you can pare it with Twitter Anywhere.

At the moment I'm working on a JS library for a webservice, you can pare it with Twitter Anywhere. Now i want to make it more test-driven. It's not easy to test because it has to work on every site that wants to make use of it, and of course with every browser.

How can i test the library efficiently?

All the API requests and responses are in JSON, is there a good way to test these calls?

I know about Cucumber and js-test-driver.

Greetings, Chielus

At the moment I'm working on a JS library for a webservice, you can pare it with Twitter Anywhere. Now i want to make it more test-driven. It's not easy to test because it has to work on every site that wants to make use of it, and of course with every browser.

How can i test the library efficiently?

All the API requests and responses are in JSON, is there a good way to test these calls?

I know about Cucumber and js-test-driver.

Greetings, Chielus

Share Improve this question edited Mar 5, 2011 at 12:33 Sachin Shanbhag 55.5k11 gold badges91 silver badges103 bronze badges asked Mar 5, 2011 at 12:27 ChielusChielus 6328 silver badges19 bronze badges 2
  • 1 Have you had a look at Jasmine ( pivotal.github./jasmine ) yet? – polarblau Commented Mar 5, 2011 at 15:45
  • I don't think i can do BDD, because it's a library that has to work with all kinds of sites. – Chielus Commented Mar 7, 2011 at 8:44
Add a ment  | 

2 Answers 2

Reset to default 5

Javascript language is dynamic by nature, so it is really test-driven friendly. I've recently got a little experience with javascript testing. I've rewrote major javascript ponents using TDD and got clear desing and more pact code!

  1. unit test framework of choice is qUnit. It is very easy to start with testing.
  2. functional test framework of choise is funcunit.

I did a blog post of testing REST api with FuncUnit here.

If you need some examples of tests and implementation, you can check my github repository.

Don't ask questions, just start testing :)

If you know about jsTestDriver I think you've already found a good solution?

You can use it to automatically launch your tests in multiple browsers and return success or failure.

This sets it apart from other tools that use headless browsers, as with jsTestDriver you're running your tests in real browsers, which seems to meet your requirements.

jsTestDriver es with its own limited assertion framework but you can plug others into it including QUnit, YUI and Jasmine.

You said above in relation to Jasmine, "I don't think i can do BDD, because it's a library that has to work with all kinds of sites.". I'm not sure what you mean by this?

Jasmine provides all the assertions to let you do the same tests as QUnit. It also lets you 'spy' on Ajax callbacks, intercept the JSON to examine or even alter it, then pass it on to your default callback. With this you could check the JSON response then check again when your UI has reacted to it in the right way.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745421602a4626988.html

相关推荐

  • tdd - Test driven development for a JavaScript library - Stack Overflow

    At the moment I'm working on a JS library for a webservice, you can pare it with Twitter Anywhere.

    5小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信