Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's your favorite way of testing javascript code snippets?

What's your favorite way of testing javascript code snippets?

I like to use the browser's address field directly:

javascript:void(document.getElementById("textbox").style.display='none'))
javascript:void(document.write("Testing"))
javascript:alert(parseFloat("33.33"))

If using the latter trick, don't forget to wrap everything in a void() call or an alert() call, lest the page will be blanked out.

Alternatively, there is the Firebug extension on firefox in which you can edit javascript code arbitrarily.

Any other interesting ways out there?

like image 528
Wadih M. Avatar asked Mar 13 '09 13:03

Wadih M.


People also ask

What is JavaScript code snippets?

Snippets are scripts that you author in the Sources panel. They have access to the page's JavaScript context, and you can run them on any page. Snippets are an alternative to bookmarklets.

What is snippet in testing?

Snippets are small scripts used in Postman which are used to verify an API. These are pre-developed scripts that can be utilized directly. Thus it helps to save a good amount of time. Snippets can be used in the Pre-request Script and Tests tabs in Postman.

What is JavaScript unit testing?

JavaScript Unit Testing is a method where JavaScript test code is written for a web page or web application module. It is then combined with HTML as an inline event handler and executed in the browser to test if all functionalities are working as desired. These unit tests are then organized in the test suite.


1 Answers

You can use JSBin to test snippets of code with snippets of html and some js frameworks.

like image 60
heeen Avatar answered Oct 14 '22 10:10

heeen