简体   繁体   English

如何更改Angular测试的Stackblitz Jasmine配置以设置“ random:false”

[英]How to change Stackblitz Jasmine configuration for Angular testing to set “random: false”

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". 在制作用于Angular测试的Stackblitz项目时,我找不到改变“以随机顺序运行测试”的默认Jasmine设置的方法。 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. Jasmine文档( 此处 )显示了多种配置方法,但是似乎没有一种方法可以在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: 如果将其添加到任何配置文件(例如main.ts )中,则会产生错误,如下所示:

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). 这些相同的文档还讨论了如何在node_modules中编辑文件,但是当然,没有办法在Stackblitz中实现(我知道)。

Here is a Stackblitz to show what I mean. 这是一个Stackblitz来展示我的意思。 Notice the tests are run in random order. 请注意,测试以随机顺序运行。 :) :)

Has anyone managed to make this work? 有没有人设法做到这一点? Thanks! 谢谢!

There is dedicated configure method on Jasmine environment: Jasmine环境上有专用的配置方法:

main.ts main.ts

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

Forked Stackblitz 分叉的Stackblitz

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM