{"id":2566,"date":"2013-05-22T17:58:33","date_gmt":"2013-05-22T17:58:33","guid":{"rendered":"http:\/\/www.webninjataylor.com\/library\/?p=2566"},"modified":"2014-06-24T21:09:39","modified_gmt":"2014-06-24T21:09:39","slug":"javascript-unit-testing","status":"publish","type":"post","link":"https:\/\/webninjataylor.com\/library\/javascript-unit-testing\/","title":{"rendered":"JavaScript Unit Testing"},"content":{"rendered":"<ul>\n<li><strong>Integration tests<\/strong> are for how users interact with an app, and <strong>unit tests<\/strong> are for small modules of code<\/li>\n<li><a href=\"http:\/\/qunitjs.com\/\" target=\"_blank\">QUnit<\/a>\u00a0is a framework for writing JavaScript unit tests<\/li>\n<\/ul>\n<h2>Simple Implementation<\/h2>\n<h3>Page (tests.php)<\/h3>\n<pre>...\r\n&lt;link rel=\"stylesheet\" href=\"css\/qunit-1.11.0.css\"&gt;\r\n...\r\n&lt;div id=\"qunit\"&gt;&lt;\/div&gt;\r\n&lt;div id=\"qunit-fixture\"&gt;&lt;\/div&gt;\r\n...\r\n&lt;script type=\"text\/javascript\" src=\"js\/qunit-1.11.0.js\"&gt;&lt;\/script&gt;\r\n&lt;script type=\"text\/javascript\" src=\"js\/tests.js\"&gt;&lt;\/script&gt;\r\n<\/pre>\n<h3>tests.js<\/h3>\n<pre>test(\"hello test\", function(){\r\n    ok( 1 == \"1\", \"Passed!\" );\r\n});\r\n<\/pre>\n<h2>Resources<\/h2>\n<ul>\n<li><a href=\"http:\/\/alistapart.com\/article\/writing-testable-javascript\" target=\"_blank\">Writing Testable JavaScript<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Integration tests are for how users interact with an app, and unit tests are for small modules of code QUnit\u00a0is a framework for writing JavaScript unit tests Simple Implementation Page (tests.php) &#8230; &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;css\/qunit-1.11.0.css&#8221;&gt; &#8230; &lt;div id=&#8221;qunit&#8221;&gt;&lt;\/div&gt; &lt;div id=&#8221;qunit-fixture&#8221;&gt;&lt;\/div&gt; &#8230; &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;js\/qunit-1.11.0.js&#8221;&gt;&lt;\/script&gt; &lt;script type=&#8221;text\/javascript&#8221; src=&#8221;js\/tests.js&#8221;&gt;&lt;\/script&gt; tests.js test(&#8220;hello test&#8221;, function(){ ok( 1 == &#8220;1&#8221;, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[144],"tags":[142,9],"class_list":["post-2566","post","type-post","status-publish","format-standard","hentry","category-web-shots","tag-debugging","tag-javascript"],"_links":{"self":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/2566","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/comments?post=2566"}],"version-history":[{"count":8,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/2566\/revisions"}],"predecessor-version":[{"id":3356,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/posts\/2566\/revisions\/3356"}],"wp:attachment":[{"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/media?parent=2566"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/categories?post=2566"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webninjataylor.com\/library\/wp-json\/wp\/v2\/tags?post=2566"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}