3

I believe it is considered to be a bad practice to rely on the order in which the (acceptance) tests should be run, but for testing "deeply nested features" (I don't know if there is a standard term for that) it might help to save time (I mean to save the time of repeating the same set of operations before each test; what I have in mind are actually Protractor tests).

So my question is whether there is a standard reliable way to fix the order in which Jasmine tests are perfomed.

2 Answers 2

6

On Jasmine 3.x, random order is the default behavior.

To run in order file written order, you can specify --random=false or use a seed.

Docs: https://jasmine.github.io/api/3.3/Configuration.html

1
  • 1
    This is super helpful. I was wondering why my tests are failing and thought random ordering is the reason. Thank you.
    – Arefe
    Aug 18, 2021 at 13:35
0

You can edit the karma.config file to change the default randomization to false. I got the answer from the following blog: https://www.miguoliang.com/how-to-fix-testing-order-in-angular-with-jasmine.html

1
  • That link goes to a 404. That's why it's best to provide the info in the post, because links can change. Sep 15, 2023 at 15:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.