2

In Ruby, you can use FactoryGirl to set factories where you save test objects. Is there such a practice in Jasmine/Karma testing?

Currently having to create a lot of instances of the same objects. I was wondering if there are any ways to do this.

Ka Mok
  • 1,937
  • 3
  • 22
  • 47
  • 1
    JS tests are still JS. If you need to create an instance to make specs DRYer, it can be a helper class or function with several lines of code. You probably should explain your case further. To my knowledge, there's no dedicated tool for fixtures, you can create them the way you want, Jasmine testing isn't about convention over configuration. – Estus Flask Jan 06 '17 at 17:15
  • I'm not familiar with FactoryGirl, but there's no reason you can't provide anything you want to the injector in the normal way. – Amy Blankenship Jan 30 '17 at 22:28

1 Answers1

2

npm has a factory-girl library inspired by the the original Ruby library. There are many other options, as well. I'd suggest searching npm for factory or faker, and select what best fits your needs.

Alison R.
  • 4,204
  • 28
  • 33