{"id":1613,"date":"2014-12-29T14:58:48","date_gmt":"2014-12-29T12:58:48","guid":{"rendered":"http:\/\/www.webcodegeeks.com\/?p=1613"},"modified":"2014-12-29T14:58:48","modified_gmt":"2014-12-29T12:58:48","slug":"avoid-test-code-duplication-in-jasmine-tests","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/","title":{"rendered":"Avoid test code duplication in Jasmine tests"},"content":{"rendered":"<p>Test code has to be treated like production code. Obviously we cannot charge the customer for it, it&#8217;s something that helps us developers to make sure we keep our codebase healthy, which ultimately is the responsibility we have towards our customers. Thus we need to apply the same best practices principles as we do for our production code, where, code duplication is evil.<\/p>\n<p>Let&#8217;s quickly take a look at some Angular code and the corresponding Jasmine test. I have the following Angular Provider which holds some functionality for handling the application menu.<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">function menuProvider(){\r\n\r\n    \/\/ expose the provider contract\r\n    this.addMenuEntry = addMenuEntry;\r\n    ...\r\n\r\n    \/\/ expose the service contract\r\n    this.$get = function(){\r\n        var service = {\r\n            addMenuEntry: addMenuEntry\r\n            ...\r\n        }\r\n        return service;\r\n    };\r\n\r\n    \/\/\/\/\/\/\/\/\/\/\/\r\n\r\n    function addMenuEntry(newEntry){\r\n        ...\r\n    }\r\n}<\/pre>\n<p>It&#8217;s not really important, but to understand the context, in Angular you have &#8220;Providers&#8221; and &#8220;Services&#8221;. The main difference is their availability during the application lifecycle (i.e. the config vs run phase). So basically if you want to have them available during both phases, you&#8217;d do something similar as I did above, namely to expose the exact same contract (or part of it) as a provider and as a service.<\/p>\n<p>Obviously, I&#8217;d like to test the availability and correct functioning of this exposed contract on both, the provider and the service class. <strong>This leads to duplicated tests<\/strong>. Let&#8217;s see this on the example of this excerpt from a Jasmine test.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">describe('The Menu's', function(){\r\n\r\n    describe('provider interface', function(){\r\n        var provider;\r\n\r\n        beforeEach(function(){\r\n            provider = \/* Angular code to inject the provider *\/;\r\n        });\r\n\r\n        it('should allow to add new menu entries', function(){\r\n            provider.addMenuEntry({\r\n                title: 'Menu title',\r\n                url: 'www.google.com'\r\n            });\r\n\r\n            \/* assertion code here *\/\r\n        });\r\n\r\n    });\r\n\r\n    describe('service interface', function(){\r\n        var service;\r\n\r\n        beforeEach(function(){\r\n            service = \/* Angular code to inject the service *\/\r\n        });\r\n\r\n        it('should allow to add new menu entries', function(){\r\n            service.addMenuEntry({\r\n                title: 'Menu title',\r\n                url: 'www.google.com'\r\n            });\r\n\r\n            \/* assertion code here *\/\r\n        });\r\n\r\n    });\r\n});<\/pre>\n<h2>Refactoring duplications<\/h2>\n<p>Guess you clearly see the duplication. On the Pivotallabs site there&#8217;s a blog post &#8220;<a href=\"http:\/\/pivotallabs.com\/drying-up-jasmine-specs-with-shared-behavior\/\">DRYing up Jasmine Specs with Shared Behavior<\/a>&#8221; which describes the possibility to factor out your <code>describe<\/code> statement into a separate function:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">function sharedTests(someParams){\r\n    describe(function(){\r\n        ...\r\n    });\r\n}<\/pre>\n<p>You can then use that function simply by invoking it within your test code:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">describe('My functionality', function(){\r\n    ...\r\n    sharedTests(...);\r\n})<\/pre>\n<p>This works like charm, with <strong>one exception<\/strong>. Usually factoring out is useful to be able to parameterize the <code>describe<\/code>, in my case to use the same tests, the first time passing in a <code>provider<\/code> instance and then the <code>service<\/code> one. Like..<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">describe('The Menu's', function(){\r\n\r\n    describe('provider interface', function(){\r\n        var provider;\r\n\r\n        beforeEach(function(){\r\n            provider = \/* Angular code to inject the provider *\/;\r\n        });\r\n\r\n        \/\/ this is the line of interest!\r\n        executeSharedTests(provider);\r\n    });\r\n\r\n    describe('service interface', function(){\r\n        var service;\r\n\r\n        beforeEach(function(){\r\n            service = \/* Angular code to inject the service *\/\r\n        });\r\n\r\n        \/\/ this is the line of interest!\r\n        executeSharedTests(service);\r\n    });\r\n\r\n    function executeSharedTests(instance){\r\n        ...\r\n    }\r\n});<\/pre>\n<p><strong>This doesn&#8217;t work<\/strong>, for the simple reason that the <code>beforeEach<\/code> is executed after the <code>executeSharedTests(...)<\/code> is being invoked, thus passing in <code>undefined<\/code>.<\/p>\n<p>To <strong>solve this problem<\/strong> you can pass in a constructor function which creates the object lazily when the test is effectively executed.<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">describe('The Menu's', function(){\r\n\r\n    describe('service interface', function(){\r\n\r\n        function createInstance(){\r\n            return \/* Angular code to inject the service *\/\r\n        }\r\n\r\n        executedSharedTests(createInstance);\r\n    });\r\n\r\n    executedSharedTests(createInstanceFn){\r\n        describe('when adding a new menu entry', function(){\r\n            var subjectUnderTest;\r\n\r\n            beforeEach(function(){\r\n                \/\/create an instance by invoking the constructor function\r\n                subjectUnderTest = createInstanceFn();\r\n            });\r\n\r\n            it('should allow to add new menu entries', function(){\r\n                ...\r\n            });\r\n        });\r\n    }\r\n});<\/pre>\n<h2>Conclusion<\/h2>\n<p>So, the whole refactored code now looks like this:<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">describe('The Menu's', function(){\r\n\r\n    describe('provider interface', function(){\r\n        var provider;\r\n\r\n        beforeEach(function(){\r\n            provider = \/* Angular code to inject the provider *\/;\r\n        });\r\n\r\n        \/\/ this is the line of interest!\r\n        executeSharedTests(provider);\r\n    });\r\n\r\n    describe('provider interface', function(){\r\n        function createInstance(){\r\n            return \/* Angular code to inject the provider *\/\r\n        }\r\n\r\n        executeSharedTests(createInstance);\r\n    });\r\n\r\n    describe('service interface', function(){\r\n        function createInstance(){\r\n            return \/* Angular code to inject the service *\/\r\n        }\r\n\r\n        executeSharedTests(createInstance);\r\n    });\r\n\r\n    executedSharedTests(createInstanceFn){\r\n        describe('when adding a new menu entry', function(){\r\n            var subjectUnderTest;\r\n\r\n            beforeEach(function(){\r\n                \/\/create an instance by invoking the constructor function\r\n                subjectUnderTest = createInstanceFn();\r\n            });\r\n\r\n            it('should allow to add new menu entries', function(){\r\n                subjectUnderTest.addMenuEntry({\r\n                    title: 'Menu title',\r\n                    url: 'www.google.com'\r\n                });\r\n\r\n                \/* assertion code here *\/\r\n            });\r\n        });\r\n    }\r\n});<\/pre>\n<h2>Related articles<\/h2>\n<ul>\n<li><a href=\"http:\/\/juristr.com\/blog\/2012\/08\/jasmine---an-introduction\/\">Jasmine &#8211; An Introduction<\/a><\/li>\n<\/ul>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/juristr.com\/blog\/2014\/10\/avoid-test-code-duplication-jasmine\/\">Avoid test code duplication in Jasmine tests<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/wcg\/\">WCG partner<\/a> Juri Strumpflohner at the <a href=\"http:\/\/juristr.com\/blog\/\">Juri Strumpflohner&#8217;s TechBlog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Test code has to be treated like production code. Obviously we cannot charge the customer for it, it&#8217;s something that helps us developers to make sure we keep our codebase healthy, which ultimately is the responsibility we have towards our customers. Thus we need to apply the same best practices principles as we do for &hellip;<\/p>\n","protected":false},"author":5,"featured_media":918,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[44],"class_list":["post-1613","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-javascript","tag-jasmine"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it&#039;s something that helps us developers to make sure we\" \/>\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.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it&#039;s something that helps us developers to make sure we\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2014-12-29T12:58:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Juri Strumpflohner\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@http:\/\/twitter.com\/juristr\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Juri Strumpflohner\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. 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.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\"},\"author\":{\"name\":\"Juri Strumpflohner\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060\"},\"headline\":\"Avoid test code duplication in Jasmine tests\",\"datePublished\":\"2014-12-29T12:58:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\"},\"wordCount\":722,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg\",\"keywords\":[\"Jasmine\"],\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\",\"name\":\"Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg\",\"datePublished\":\"2014-12-29T12:58:48+00:00\",\"description\":\"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it's something that helps us developers to make sure we\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"JavaScript\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/javascript\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Avoid test code duplication in Jasmine tests\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060\",\"name\":\"Juri Strumpflohner\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g\",\"caption\":\"Juri Strumpflohner\"},\"description\":\"Juri Strumpflohner mainly operates in the web sector developing rich applications with HTML5 and JavaScript. Beside having a Java background and developing Android applications he currently works as a software architect in the e-government sector. When he\u2019s not coding or blogging about his newest discoveries, he is practicing Yoseikan Budo where he owns a 2nd DAN.\",\"sameAs\":[\"http:\/\/juristr.com\/blog\/\",\"http:\/\/linkedin.com\/in\/juristr\/\",\"https:\/\/x.com\/http:\/\/twitter.com\/juristr\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/juri-strumpflohner\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026","description":"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it's something that helps us developers to make sure we","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.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/","og_locale":"en_US","og_type":"article","og_title":"Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026","og_description":"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it's something that helps us developers to make sure we","og_url":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2014-12-29T12:58:48+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg","type":"image\/jpeg"}],"author":"Juri Strumpflohner","twitter_card":"summary_large_image","twitter_creator":"@http:\/\/twitter.com\/juristr","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Juri Strumpflohner","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/"},"author":{"name":"Juri Strumpflohner","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060"},"headline":"Avoid test code duplication in Jasmine tests","datePublished":"2014-12-29T12:58:48+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/"},"wordCount":722,"commentCount":2,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg","keywords":["Jasmine"],"articleSection":["JavaScript"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/","url":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/","name":"Avoid test code duplication in Jasmine tests - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg","datePublished":"2014-12-29T12:58:48+00:00","description":"Test code has to be treated like production code. Obviously we cannot charge the customer for it, it's something that helps us developers to make sure we","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/jasminejs-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/javascript\/avoid-test-code-duplication-in-jasmine-tests\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"JavaScript","item":"https:\/\/www.webcodegeeks.com\/category\/javascript\/"},{"@type":"ListItem","position":3,"name":"Avoid test code duplication in Jasmine tests"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/33d3ee7edb105a80f1ff7199925b3060","name":"Juri Strumpflohner","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/45338315375849845e4c4b30f52cb417221e2d9a7e688785e4dd2af0e624a260?s=96&d=mm&r=g","caption":"Juri Strumpflohner"},"description":"Juri Strumpflohner mainly operates in the web sector developing rich applications with HTML5 and JavaScript. Beside having a Java background and developing Android applications he currently works as a software architect in the e-government sector. When he\u2019s not coding or blogging about his newest discoveries, he is practicing Yoseikan Budo where he owns a 2nd DAN.","sameAs":["http:\/\/juristr.com\/blog\/","http:\/\/linkedin.com\/in\/juristr\/","https:\/\/x.com\/http:\/\/twitter.com\/juristr"],"url":"https:\/\/www.webcodegeeks.com\/author\/juri-strumpflohner\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=1613"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/1613\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/918"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=1613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}