如何编写JavaScript的测试用例

时间:2021-01-02 01:20:13

I have Rails Application which uses JavaScript Extensively.

我有Rails应用程序,它广泛使用JavaScript。

I would like to know is there any tool (Similar to Rspec, Cucumber For Rails)using which i can test the JS Code Written in my application.

我想知道是否有任何工具(类似于Rspec,Cucumber For Rails)使用它可以测试我的应用程序中编写的JS代码。

What is the best practice to ensure that your JS is proper?

确保JS正确的最佳做法是什么?

3 个解决方案

#1


0  

There are several JavaScript unit testing tools. Among the ones I have used are:

有几个JavaScript单元测试工具。我使用的是:

Web searches for these will turn up lots of comparisons, tutorials, and other articles about using them. There's an article here on using Jasmine with Rails.

网络搜索这些内容将会出现大量有关使用它们的比较,教程和其他文章。这里有一篇关于使用Jasmine和Rails的文章。

There's a nice article here comparing several JavaScript testing suites for use with Rails.

这里有一篇很好的文章比较了几个用于Rails的JavaScript测试套件。

#2


3  

use jasmine.

http://pivotal.github.com/jasmine/

and combine it with jTestDrive to test different browsers. http://code.google.com/p/js-test-driver/

并将其与jTestDrive结合使用以测试不同的浏览器。 http://code.google.com/p/js-test-driver/

jasmine is used for the test cases and jsTestDrive is used for executing the tests on diffrent browsers.

jasmine用于测试用例,jsTestDrive用于在不同的浏览器上执行测试。

Fell free to ask if you need more info

如果您需要更多信息,请随时询问

#3


0  

You can try jasminerice gem git link https://github.com/bradphelan/jasminerice

你可以尝试jasminerice gem git链接https://github.com/bradphelan/jasminerice

#1


0  

There are several JavaScript unit testing tools. Among the ones I have used are:

有几个JavaScript单元测试工具。我使用的是:

Web searches for these will turn up lots of comparisons, tutorials, and other articles about using them. There's an article here on using Jasmine with Rails.

网络搜索这些内容将会出现大量有关使用它们的比较,教程和其他文章。这里有一篇关于使用Jasmine和Rails的文章。

There's a nice article here comparing several JavaScript testing suites for use with Rails.

这里有一篇很好的文章比较了几个用于Rails的JavaScript测试套件。

#2


3  

use jasmine.

http://pivotal.github.com/jasmine/

and combine it with jTestDrive to test different browsers. http://code.google.com/p/js-test-driver/

并将其与jTestDrive结合使用以测试不同的浏览器。 http://code.google.com/p/js-test-driver/

jasmine is used for the test cases and jsTestDrive is used for executing the tests on diffrent browsers.

jasmine用于测试用例,jsTestDrive用于在不同的浏览器上执行测试。

Fell free to ask if you need more info

如果您需要更多信息,请随时询问

#3


0  

You can try jasminerice gem git link https://github.com/bradphelan/jasminerice

你可以尝试jasminerice gem git链接https://github.com/bradphelan/jasminerice