More Related Content More from Eyal Vardi (20) Advanced java script unit testing - js-il.com1. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference
Yaniv@UpStruct.net
http://www.UpStruct.net
2. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Israel JavaScript Conference
Yaniv@UpStruct.net
http://www.UpStruct.net
10. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Suitest
DOH
JSUnit
LBRTW UT
http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript
12. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Suitest
DOH
JSUnit
LBRTW UT
http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#JavaScript
19. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<!DOCTYPE html>
<html>
<head>
<link href="Scripts/libs/qunit/qunit-1.10.0.css‛
rel="stylesheet" type="text/css" />
<script src="Scripts/libs/qunit/qunit-1.10.0.js"
type="text/javascript"></script>
<script src="Scripts/my-tests.js"
type="text/javascript"></script>
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
</body>
</html>
20. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
test(‚Sanity Test", function () {
ok(1 == 1, 'Hello QUnit‘);
});
24. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
module("Tests and Modules", {
// Runs before each test
setup: function () {
},
// Runs after each test
teardown: function () {
}
});
test(‚Sanity Test", function () {
ok(1 == 1, 'Hello QUnit‘);
});
28. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
<!DOCTYPE html>
<html>
<head>
<link href="Scripts/libs/qunit/qunit-1.10.0.css‚
rel="stylesheet" type="text/css" />
<script src="Scripts/libs/qunit/qunit-1.10.0.js"
type="text/javascript"></script>
<script data-main="scripts/main-tests"
src="scripts/libs/require/require.js"
type="text/javascript"></script>
</head>
</html>
29. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
Data what?
<div id=‚product‛ data-identity=‚3‛>…</div>
var productId = $(‘#product’).data(‘identity’);
30. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
require(["jquery",
"underscore‚
], function ($, _) {
module("Tests and Modules", {
setup: function () {
},
teardown: function () {
}
});
test(‚Sanity Test", function () {
ok(1 == 1, 'Hello QUnit‘);
});
});
34. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
http://code.google.com/p/js-test-driver
https://github.com/exnor/QUnit-to-
JsTestDriver-adapter
36. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
server: http://localhost:9876
basepath: ""
load:
- jquery.js
- qunit.js
- sinon.js
test:
- test.js
serve:
- module.js
plugin:
# Plug-Ins
37. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
-jar JsTestDriver.jar --port 9876
--browser
"chrome.exe","Safari.exe‚, ‚iexplore.exe‛
-jar JsTestDriver-1.3.5.jar
--server http://localhost:9876
--tests all
--testOutput "jsTestDriver-TestResults"
--verbose
41. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
http://sinonjs.org
http://sinonjs.org/qunit
http://sinonjs.org/docs/#server
43. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
require(["jquery",
"underscore",
"tests/calculator"
], function ($, _, calculator) {
test("Stub method", function () {
var stub = sinon.stub(calculator, "sum",
function (num1, num2) {
return num1 - num2;
});
var sum = calculator.sum(5, 3);
equal(sum, 2, "Expected 2");
stub.restore();
});
});
49. Israel JavaScript Conference | 03 – 6325707 | info@e4d.co.il | www.js-il.com |
http://en.wikipedia.org/wiki/List_of_unit_testing_framewor
ks#JavaScript
Part I Part II Part III
Editor's Notes It’s very much like regular exercise. Everybody knows it’s good, but few people do it. It’s very much like regular exercise. Everybody knows it’s good, but few people do it. It’s very much like regular exercise. Everybody knows it’s good, but few people do it.