Factsheet
browser - Load local javascript file in chrome for testing? - Stack Overflow
How do you unit test javacript on a website?
Firefox 4 edges out Chrome in SunSpider test
May the JavaScript speed war continue forever.
More on reddit.comShould I test JavaScript In Node.js or a browser
What is a JavaScript compiler?
How fast is the online JavaScript compiler?
Does the JavaScript compiler work offline?
Videos
Sorry for asking this I suposse this gets asked a lot here but I could not find any info on the matter.
I am learning js for web developing but I already know python. I have been learning for 2 days and today I started js codewars.
Everytime I want to set up an exercise I have to create an html file, link the file to the html, launch the html in the browser, write the code in the js file, open the console on firefox and check if my function has the correct output (I use console.log to check)
It gets old real quick when you have to do that 10 times a day. In python I would just click "run" and that's it.
Is there anyway to check the output on vs code without having to set up the whole thing?
If you are trying to just test the functionality of your JavaScript file: create a blank HTML file, add a link to your JS file as you would normally load a JS file from HTML, and open the HTML file in Chrome. Go to the JavaScript console. You'll be able to interact with the functionality of your JS code as usual. You wouldn't need to set up a server for this. If still not clear, here's an example:
<html>
<head>
<script type = "text/javascript" src = "path/to/your/jsfile"></script>
</head>
</html>
You can use a light weight webserver to serve the file.
For example,
1. install Node
2. install the "http-server" (or similar) package
3. Run the http-server package ( "http-server -c-1") from the folder where the script file is located
4. Load the script from chrome console (run the following script on chrome console
var ele = document.createElement("script");
var scriptPath = "http://localhost:8080/{scriptfilename}.js" //verify the script path
ele.setAttribute("src",scriptPath);
document.head.appendChild(ele)
- The script is now loaded the browser. You can test it from console.
I'm pulling my hair out trying to figure out how to unit test my website's javascript. It seems like most popular tools (ex. Mocha) only work in Node.JS.