# Avoid test code duplication in Jasmine tests

DevFeed: [Avoid test code duplication in Jasmine tests](<https://devfeed.tech/articles/avoid-test-code-duplication-in-jasmine-tests-21223.md>)

Original publisher: [Read original article](<https://juri.dev/blog/2014/10/avoid-test-code-duplication-jasmine/>)

Published: 2014-10-29T00:00:00Z

Content type: article

Language: en

Sources: [Juri Strumpflohner](<https://devfeed.tech/sources/juri-strumpflohner.md>)

Topics: [Jasmine](<https://devfeed.tech/topics/jasmine.md>), [test](<https://devfeed.tech/topics/test.md>), [Refactoring](<https://devfeed.tech/topics/refactoring.md>), [Code](<https://devfeed.tech/topics/code.md>), [Angular](<https://devfeed.tech/topics/angular.md>)

Tags: [angular](<https://devfeed.tech/tags/angular.md>), [exception](<https://devfeed.tech/tags/exception.md>), [providers](<https://devfeed.tech/tags/providers.md>), [refactoring](<https://devfeed.tech/tags/refactoring.md>), [test](<https://devfeed.tech/tags/test.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This tutorial explains how to remove duplicated test code in Jasmine when testing equivalent functionality exposed through an Angular provider and service. It demonstrates extracting shared behavior into a function and passing a constructor function to create test objects lazily when the tests run.

## Source excerpt

Lorem ipsum dolor sit amet