Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the seed randomization number from jasmine

Jasmine (node js docs) allows you to randomize your tests

--random=[true|false]

Tells jasmine to run specs in semi random order or not for this run, overriding jasmine.json

jasmine --random=true

and also allows you to fine tune the randomization, by providing a seed number.

--seed=

Sets the randomization seed if randomization is turned on

jasmine --seed=4321

However, is it possible to get the seed number from a random execution?

The use case is quite simple - you have 3 specs and the suite fails only if the order of execution is 3 -> 1 -> 2.

You execute this suite using --random=true and on failure you'd want to know what randomization seed generated the failure, so that you can reproduce it later on by just providing the seed number to the jasmine runner.

Does jasmine provide this feature? If yes, how can it be done?

like image 657
Adelin Avatar asked Jan 08 '18 07:01

Adelin


1 Answers

I had the same problem, but I was using Karma to run my tests in the browser. I used this gist to create a Karma reporter to log the jasmine random seed. https://gist.github.com/odlp/e1586f4f198d157de50e8303b18acfd9

If you are a not using Karma, it may at least give you some ideas.

like image 98
Guilherme Dellagustin Avatar answered Oct 24 '22 06:10

Guilherme Dellagustin