How to change Stackblitz Jasmine configuration for Angular testing to set "random: false"

366 Views Asked by At

When making a Stackblitz project for Angular testing, there is no way I have found to change the default Jasmine setting of "run tests in random order". Of course I can click on the OPTIONS box and change it manually, but I would like to create projects with a different default.

The Jasmine docs (here) show a number of ways to configure this, but none of them appear to work in Stackblitz. For example, adding the code:

jasmine.loadConfig({
    random: false
});

Produces an error if added to any of the configuration files (for example main.ts) as follows:

Error in /~/main.ts (30:5)
jasmine.loadConfig is not a function

Those same docs also talk about editing the file in node_modules, but of course there is no way of getting to that in Stackblitz (that I know of).

Here is a Stackblitz to show what I mean. Notice the tests are run in random order. :)

Has anyone managed to make this work? Thanks!

1

There are 1 best solutions below

1
On BEST ANSWER

There is dedicated configure method on Jasmine environment:

main.ts

jasmine.getEnv().configure({random: false}); // add this
bootstrap();

Forked Stackblitz