{"id":1371,"date":"2012-11-29T09:47:13","date_gmt":"2012-11-29T09:47:13","guid":{"rendered":"http:\/\/www.robertprice.co.uk\/robblog\/?p=1371"},"modified":"2012-11-29T09:47:13","modified_gmt":"2012-11-29T09:47:13","slug":"unit-testing-javascript-with-qunit","status":"publish","type":"post","link":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/","title":{"rendered":"Using QUnit To Unit Test JavaScript"},"content":{"rendered":"<p>In this article I wanted to give you an introduction to unit testing in JavaScript using <a href=\"http:\/\/qunitjs.com\/\">QUnit<\/a>.<\/p>\n<p>QUnit was originally developed by John Resig for testing jQuery, but it is now a stand alone project, without any dependancies on jQuery.<\/p>\n<h2>A quick example of using QUnit<\/h2>\n<p>Firstly, you need to download <a href=\"http:\/\/code.jquery.com\/qunit\/qunit-1.10.0.js\">qunit.js<\/a> and <a href=\"http:\/\/code.jquery.com\/qunit\/qunit-1.10.0.css\">qunit.css<\/a>, and store them locally.<\/p>\n<p>Secondly you need to create an HTML page something like this to run your tests in.<\/p>\n<pre class=\"lang:xhtml decode:true \" >&lt;!DOCTYPE html&gt;\n\n&lt;html&gt;\n\t&lt;head&gt;\n\t\t&lt;meta charset=\"utf-8\"&gt;\n\t\t&lt;title&gt;QUnit Example&lt;\/title&gt;\n\t\t&lt;link rel=\"stylesheet\" href=\".\/qunit.css\"&gt;\n\t\t&lt;script src=\".\/qunit.js\"&gt;&lt;\/script&gt;\n\t\t&lt;script src=\".\/test.js\"&gt;&lt;\/script&gt;\n\t&lt;\/head&gt;\n\t&lt;body&gt;\n\t\t&lt;div id=\"qunit\"&gt;&lt;\/div&gt;\n\t&lt;\/body&gt;\n&lt;\/html&gt;<\/pre>\n<p>You&#8217;ll notice the references to qunit.css and qunit.js are to the two files we downloaded just now. tests.js is the file where we&#8217;ll be placing our unit tests, and we&#8217;ll be creating this shortly. Finally, you&#8217;ll also see a <code>&lt;div&gt;<\/code> with an id of <var>qunit<\/var>. Ths is where the results of our unit tests will be displayed.<\/p>\n<p>One of the simpliest tests is testing for true. Create a file called test.js and add the following.<\/p>\n<pre class=\"lang:js decode:true \" >test(\"testing for true\", function() {\n\tok(true, \"true is true\");\n});<\/pre>\n<p>This should give us a result like looking like this.<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png\" alt=\"QUnit Results\" title=\"qunit1\" width=\"522\" height=\"208\" class=\"alignnone size-full wp-image-1377\" \/><\/a><\/p>\n<p>We can see that one test was successfully run, and that there were no errors found.<\/p>\n<p>The name of our test, &#8220;testing for true&#8221; is shown, and clicking onto this expands the result and shows our success message &#8220;true is true&#8221;.<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit211.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit211.png\" alt=\"Qunit Results\" title=\"qunit2\" width=\"525\" height=\"246\" class=\"alignnone size-full wp-image-1378\" \/><\/a><\/p>\n<p>So what is going on?<\/p>\n<p>Well, we are calling the <code>test<\/code> function from QUnit, and we are passing in a name for our test &#8211; &#8220;testing for true&#8221;, and a function to execute the test in. Inside this function we calling the assertion <code>ok<\/code> from QUnit, passing in a value to test for truth against &#8211; in this case <var>true<\/var>, and a message about the assertion &#8211; &#8220;true is true&#8221;.<\/p>\n<p>When the page is loaded into a browser, the script is run and the results of our unit test shown in the <var>qunit<\/var> <code>&lt;div&gt;<\/code>.<\/p>\n<h2>Testing For Equality<\/h2>\n<p>One of the most common unit tests is to compare the expected and actual values from a function.<\/p>\n<p>QUnit has the <code>equal<\/code> assertion to help us here. Let&#8217;s add some more tests to test.js.<\/p>\n<pre class=\"lang:js decode:true \" >test(\"testing equality\", function() {\n\tequal(1, 1, \"1 is 1\");\n\tequal(\"1\",\"1\", \"\"1\" is \"1\"\");\n\tequal(1, \"1\", \"1 is \"1\"\");\n\tequal(1, true, \"1 is true\");\n\tequal(1, !false, \"1 is not false\");\n});<\/pre>\n<p>Run this and expand the results for &#8220;testing equality&#8221;, it should look something like this&#8230;<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit311.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit311.png\" alt=\"Qunit Results\" title=\"qunit3\" width=\"523\" height=\"381\" class=\"alignnone size-full wp-image-1379\" \/><\/a><\/p>\n<p>You should see the obvious results such as 1 and 1 being equal, and &#8220;1&#8221; and &#8220;1&#8221; being equal. You should also see that 1 is the same as &#8220;1&#8221; as JavaScript is converting between types and checking the values are the same. Finally, you can see that 1 is also true, and not false, this is because 1 is truthy in JavaScript. The point to remember here is that the <code>equal<\/code> assertion behaves like JavaScript&#8217;s <code>==<\/code> comparator.<\/p>\n<p>There may be occassions where you need to compare the value <strong>and<\/strong> the type, so the number 1 isn&#8217;t the same as the string &#8220;1&#8221;. In these situations we need to use the <code>strictEqual<\/code> assertion as this works like JavaScript&#8217;s <code>===<\/code> comparator.<\/p>\n<p>Let&#8217;s add some more assertions to our &#8220;testing equality&#8221; test.<\/p>\n<pre class=\"lang:js decode:true \" >\n\tstrictEqual(1, \"1\", \"1 is \"1\"\");\n<\/pre>\n<p>Running this we can see that the number 1 is not the same as the string &#8220;1&#8221;, and QUnit has thrown an error to tell us this.<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit411.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit411.png\" alt=\"Qunit Results\" title=\"qunit4\" width=\"525\" height=\"456\" class=\"alignnone size-full wp-image-1380\" \/><\/a><\/p>\n<p>However this isn&#8217;t very useful, as we know that 1 isn&#8217;t really &#8220;1&#8221;, so we want to test for this. This is where QUnit&#8217;s <code>notStrictEqual<\/code> assertion will come in handy, as it tests for false results.<\/p>\n<p>Replace the strictEqual with the following&#8230;<\/p>\n<pre class=\"lang:js decode:true \" >\n\tnotStrictEqual(1, \"1\", \"1 is not \"1\"\");\n<\/pre>\n<p>Running this we can see that the number 1 is not the same as the string &#8220;1&#8221;, and QUnit has tested successfully for this.<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit511.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit511.png\" alt=\"QUnit Results\" title=\"qunit5\" width=\"525\" height=\"407\" class=\"alignnone size-full wp-image-1381\" \/><\/a><\/p>\n<p>It&#8217;s useful to be able to compare objects, so let&#8217;s try this but adding the following code&#8230;<\/p>\n<pre  class=\"lang:js decode:true \">\n\tvar a = {'name' : 'rob'};\n\tvar b = a;\n\tequal(a, b, \"variables a and b are equal\");\n\tb = {'name' : 'rob'};\n\tequal(a, b, \"variables a and b are equal\");\n<\/pre>\n<p>Running this we see that our first asserting that a and b are equal is correct, however, creating what looks like the same object and testing equality fails.<\/p>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit611.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit611.png\" alt=\"QUnit Results\" title=\"qunit6\" width=\"523\" height=\"502\" class=\"alignnone size-full wp-image-1382\" \/><\/a><\/p>\n<p>This is because we&#8217;re not testing the actual contents of the object, just that the reference the variable points to is the same. In the first case they both point to the same object, in the second case they are different objects.<\/p>\n<p>QUnit has another equality function called <code>deepEqual<\/code> that compares the content of an object with the content of another object. Let&#8217;s change the failing <code>equal<\/code> in our last example with the <code>deepEqual<\/code> and try again.<\/p>\n<pre class=\"lang:js decode:true \">\n\tdeepEqual(a, b, \"contents of variables a and b are equal\");\n<\/pre>\n<p><a href=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit711.png\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit711.png\" alt=\"QUnit Results\" title=\"qunit7\" width=\"522\" height=\"460\" class=\"alignnone size-full wp-image-1383\" \/><\/a><\/p>\n<p>Our tests are working again now, as we are now comparing the actual contents of the objects.<\/p>\n<h2>Summary<\/h2>\n<p>QUnit can do much more than just testing for equality and I hope to touch on some of the other functionality in another article soon. However, I hope this basic overview has been a useful introduction to unit testing JavaScript and has provided enough information to get you started in testing your own JavaScript code.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article I wanted to give you an introduction to unit testing in JavaScript using QUnit. QUnit was originally developed by John Resig for testing jQuery, but it is now a stand alone project, without any dependancies on jQuery. A quick example of using QUnit Firstly, you need to download qunit.js and qunit.css, and &hellip; <a href=\"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Using QUnit To Unit Test JavaScript&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[2],"tags":[31,54,70],"class_list":["post-1371","post","type-post","status-publish","format-standard","hentry","category-dev","tag-javascript","tag-qunit","tag-unit-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Using QUnit To Unit Test JavaScript - Robert Price<\/title>\n<meta name=\"description\" content=\"An overview of unit testing JavaScript using QUnit.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using QUnit To Unit Test JavaScript - Robert Price\" \/>\n<meta property=\"og:description\" content=\"An overview of unit testing JavaScript using QUnit.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/\" \/>\n<meta property=\"og:site_name\" content=\"Robert Price\" \/>\n<meta property=\"article:published_time\" content=\"2012-11-29T09:47:13+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png\" \/>\n<meta name=\"author\" content=\"rob\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"rob\" \/>\n\t<meta name=\"twitter:label2\" content=\"Estimated reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/\"},\"author\":{\"name\":\"rob\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"headline\":\"Using QUnit To Unit Test JavaScript\",\"datePublished\":\"2012-11-29T09:47:13+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/\"},\"wordCount\":764,\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/wp-content\\\/uploads\\\/2012\\\/11\\\/qunit111.png\",\"keywords\":[\"JavaScript\",\"qunit\",\"unit testing\"],\"articleSection\":[\"Dev\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/\",\"name\":\"Using QUnit To Unit Test JavaScript - Robert Price\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#primaryimage\"},\"thumbnailUrl\":\"http:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/wp-content\\\/uploads\\\/2012\\\/11\\\/qunit111.png\",\"datePublished\":\"2012-11-29T09:47:13+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\"},\"description\":\"An overview of unit testing JavaScript using QUnit.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#primaryimage\",\"url\":\"http:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/wp-content\\\/uploads\\\/2012\\\/11\\\/qunit111.png\",\"contentUrl\":\"http:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/wp-content\\\/uploads\\\/2012\\\/11\\\/qunit111.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/unit-testing-javascript-with-qunit\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Using QUnit To Unit Test JavaScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#website\",\"url\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/\",\"name\":\"Robert Price\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.robertprice.co.uk\\\/robblog\\\/#\\\/schema\\\/person\\\/fac6d5b076e0e14e1fb13e15b542a6c5\",\"name\":\"rob\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g\",\"caption\":\"rob\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using QUnit To Unit Test JavaScript - Robert Price","description":"An overview of unit testing JavaScript using QUnit.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/","og_locale":"en_GB","og_type":"article","og_title":"Using QUnit To Unit Test JavaScript - Robert Price","og_description":"An overview of unit testing JavaScript using QUnit.","og_url":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/","og_site_name":"Robert Price","article_published_time":"2012-11-29T09:47:13+00:00","og_image":[{"url":"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png","type":"","width":"","height":""}],"author":"rob","twitter_card":"summary_large_image","twitter_misc":{"Written by":"rob","Estimated reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#article","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/"},"author":{"name":"rob","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"headline":"Using QUnit To Unit Test JavaScript","datePublished":"2012-11-29T09:47:13+00:00","mainEntityOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/"},"wordCount":764,"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#primaryimage"},"thumbnailUrl":"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png","keywords":["JavaScript","qunit","unit testing"],"articleSection":["Dev"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/","url":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/","name":"Using QUnit To Unit Test JavaScript - Robert Price","isPartOf":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#primaryimage"},"image":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#primaryimage"},"thumbnailUrl":"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png","datePublished":"2012-11-29T09:47:13+00:00","author":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5"},"description":"An overview of unit testing JavaScript using QUnit.","breadcrumb":{"@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/"]}]},{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#primaryimage","url":"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png","contentUrl":"http:\/\/www.robertprice.co.uk\/robblog\/wp-content\/uploads\/2012\/11\/qunit111.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.robertprice.co.uk\/robblog\/unit-testing-javascript-with-qunit\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.robertprice.co.uk\/robblog\/"},{"@type":"ListItem","position":2,"name":"Using QUnit To Unit Test JavaScript"}]},{"@type":"WebSite","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#website","url":"https:\/\/www.robertprice.co.uk\/robblog\/","name":"Robert Price","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.robertprice.co.uk\/robblog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Person","@id":"https:\/\/www.robertprice.co.uk\/robblog\/#\/schema\/person\/fac6d5b076e0e14e1fb13e15b542a6c5","name":"rob","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/6f0eb511179100a4e968abc70403e33686e6ab3e992e392bedd2ccac01da666c?s=96&d=mm&r=g","caption":"rob"}}]}},"_links":{"self":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/1371","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/comments?post=1371"}],"version-history":[{"count":0,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/posts\/1371\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/media?parent=1371"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/categories?post=1371"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.robertprice.co.uk\/robblog\/wp-json\/wp\/v2\/tags?post=1371"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}