Hello: though new to nodejs and mocha, SO has been making it easier for me understand it. i am here with another question seeking your help.
I am trying to run a mocha test via the browser (not the terminal). The test is to try access a url and get the response status.
Below is a working script using XMLHttpRequest
. However, i want to use a node library (say request.js). Please help.
test.js
describe('suite', function(){
it('case', function(done){
var url = "http://oss.sheetjs.com/js-xlsx/test_files/formula_stress_test_ajax.xlsx";
var xhr = new XMLHttpRequest();
xhr.open("GET", url, true);
xhr.onload = function (e) {
console.log("TEST RESPONSE STATUS IS: " + xhr.status);
}
xhr.send();
done();
});
});
testrunner.html
<!DOCTYPE html>
<html>
<head>
<title>Mocha Tests</title>
<link rel="stylesheet" href="../node_modules/mocha/mocha.css">
</head>
<body>
<div id="mocha"></div>
<script src="../node_modules/mocha/mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="./test.js"></script>
<script>
mocha.run()
</script>
</body>
</html>
via Bipo K
No comments:
Post a Comment