QUnit is only running the first test - unit-testing

I can't get QUnit to run any test after the first. To be sure I wasn't doing something weird, I pared down the code to be as basic as possible.
test("A", function () {
ok(true, "Test A");
});
test("B", function () {
ok(true, "Test B");
});
Test A is the only one that runs. No errors thrown or anything else.
My HTML file looks like this.
<!DOCTYPE html>
<html>
<head>
<title>Test title</title>
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.10.0.css">
</head>
<body>
<div id="qunit"></div>
<script src="http://code.jquery.com/qunit/qunit-1.10.0.js"></script>
<script src="tests.js" type="text/javascript"></script>
</body>
</html>

Found the problem. It was this!
qunit.html?testNumber=1
I guess at some point I hit rerun and it ignored the other tests!
This other question deserves credit for pointing me in the right direction. QUnit Won't Run Tests

very similar to Mims H. Wright's answer.
I also hit "rerun" on a failing test, and it appended the testId to my url, which I didnt notice.
tests.html?testId=fb134038

Related

how to setup qunit to ignore certain files?

I have the following setup in my qUnit.html file
<html>
<head>
<Title> Batch Processing Tool Unit Test Report</Title>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<meta charset="utf-8">
<script id="sap-ui-bootstrap"
src="../../openui5/resources/sap-ui-core.js"
data-sap-ui-resourceroots='{
"BatchProcessing": "../../",
"test.unit": "./"
}'
data-sap-ui-frameOptions='deny'>
</script>
<script>
jQuery.sap.require("sap.ui.qunit.qunit-css");
jQuery.sap.require("sap.ui.thirdparty.qunit");
jQuery.sap.require("sap.ui.qunit.qunit-junit");
jQuery.sap.require("sap.ui.qunit.qunit-coverage");
QUnit.config.autostart = false;
sap.ui.require(
[
"test/unit/controller/InputsView.controller",
"test/unit/controller/TableView.controller",
"test/unit/controller/DetailsView.controller"
],
function() {
setTimeout(function() {
QUnit.start();
}, 5000);
}
);
</script>
</head>
<body>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>
</body>
</html>
The problem is that when I go to look at my code coverage qUnit tries to cover every .js file in my project. How can I tell it to ignore certain files that I don't want to test. Is it possible to do it within the qUnit.html file or does it have to be strictly done through grunt?
I found an answer after looking around for a while. Here it is for anyone running into similar problems.
https://openui5.hana.ondemand.com/#/topic/7ef32428dc7c4c048a8d7e8de0a556fb

How can you set up Unit Testing(qUnit) with an SAPUI5 Application?

I'm trying to implement unit testing within my SAPUI5 Application. I understand how to perform the unit tests --but I'm not understanding how to configure the testing in my SAP UI5 application. I believe the problem is how I'm attempting to load in the controller I want to test. I have a basic tree structure like so:
I'm unfamiliar with how to set up the tests. When I insert the following controller, I get a script error:
test.js
sap.ui.require(["../Controller/Main.controller.js"],
function(MyController){
//Quint code
test("hello test", function(assert) {
assert.ok(1 == "1", "Passed!");
});
});
initialTest.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.15.0.css">
<script id="sap-ui-bootstrap"
src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js">
</script>
<script src="//code.jquery.com/qunit/qunit-1.15.0.js"></script>
<script src="tests.js"></script>
<script src="/Controller/Main.controller.js"></script>
<script>
</script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
screenshot of the error
How can I properly load in the controller.js that I would like to test?
Try including like this
jQuery.sap.registerModulePath("controller", "../Controller");
jQuery.sap.require({
modName : "controller.Main",
type : "controller"
});
QUnit.test("Some text", function() {
var oCont = sap.ui.controller("controller.Main");
});

Instafeed tutorial, pictures are not loading

I am trying to implement the instafeed tutorial to just show some instagram pictures.
I am working on PyCharm using Django.
Here is my folder hierarchy:
/test_project/js/instafeed.min.js
I have a suspicion that I am not referencing the 'src' correctly. I had 'Cannot resolve directory' warnings before, but I got them to disappear by playing around with the Source preferences.
Here's the HTML code:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<style>
</style>
<script type="text/javascript" src="/js/instafeed.min.js"></script>
<script type="text/javascript">
var feed = new Instafeed({
get: 'tagged',
tagName: 'awesome',
clientId: 'b8dacdbf587f41798d8dfb03e3f7a29',
useHTTP: true
});
feed.run();
</script>
</head>
<body>
<div id="instafeed">
</div>
</body>
</html>
I used the 'useHTTP:true' because I saw on another answer that this needs to be set to true to work on a local machine. I've looked at how the code was used in other tutorials and implementations, but I don't see how my code is any different.
Thanks for the help!
Instafeed needs jQuery (the documentation says that you don't need, but i got some errors without it), so make sure you have both libs loaded correctly.
Try with this:
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="//cdn.lukej.me/instafeed.js/1.2.0/instafeed.min.js"></script>

Making clock in javascript but Raphael not defined

I am making a clock in javascript. The code below is just the start. It should produce an orange rectangle only.
I am using the raphael library for the vector graphics.
However, when i try and view this in a web browser, in the inspect element i get a message saying that raphael is undefined.
I have stored my clock.html and clock.js file in a folder that contains only raphael-min.js
I have the html code as follows
<!DOCTYPE HTML>
<html>
<head>
<script src="Clock.js" type="text/javascript"> </script>
<script src=“raphael-min.js" type="text/javascript"> </script>
</head>
<body>
</body>
</html>
and the java code as follows
window .onload= function (){
var paper = new Raphael( 0, 0, 400, 400);
var backGround = paper.rect(0, 0, 400, 400);
backGround.attr({ fill: "orange"});
/* Comment - Add your code here*/
};`
If someone could please tell me what I am doing wrong, that would be fantastic. In plain english please. I started learning html and javascript last week.
Many thanks
Always add the scripts your code uses before you add your code.
Like this:
<!DOCTYPE HTML>
<html>
<head>
<script src=“raphael-min.js"></script>
<script src="Clock.js"></script>
</head>
<body>
</body>
</html>
In the question, Clock.js appears first. That's probably why you are getting the Raphael undefined error.
I removed type="text/javascript". You'll find that in older JS books and tutorials but it is unnecessary.

Message in script never gets passed

I have been trying to get the following code that I got from the Facebook Developer site to work properly from a Lotus Domino application:
<html>
<head>
<title>My Great Website</title>
</head>
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:####################, cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'feed',
message: 'Facebook for Websites is super-cool'});
</script>
</body>
The popup opens (only from Firefox, not from IE) but the message text never gets passed. Any ideas why? Any help would be much appreciated.
The message field has been deprecated. The user must enter their own message into that box. The documentation is wrong.