You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在jasmine-ts 0.3.0中指定特定种子执行测试?

How to Set Test Seed in jasmine-ts 0.3.0

I’ve run into exactly this issue with jasmine-ts 0.3.0 before, and there are two reliable workarounds to specify a seed for reproducing random test failures:

1. Override Random Mode and Seed via Command Line

The problem with your initial command is that the random: true in your jasmine.json takes precedence over the standalone --seed flag. To fix this, explicitly pass both --random=true and --seed=<your-seed> in the command line — this will override the configuration file’s random setting and enforce your specified seed:

jasmine-ts --random=true --seed=123 --config="./jasmine.json"

This works because jasmine-ts respects command-line arguments for both randomization and seed when they’re explicitly provided, even if the config file has conflicting settings.

2. Use the JASMINE_SEED Environment Variable

Jasmine (and by extension jasmine-ts) supports setting the seed via an environment variable, which bypasses the configuration file’s randomization settings entirely. This is especially useful if you don’t want to modify your jasmine.json or remember to pass multiple flags.

For Linux/macOS:

JASMINE_SEED=123 jasmine-ts --config="./jasmine.json"

For Windows Command Prompt:

set JASMINE_SEED=123 && jasmine-ts --config="./jasmine.json"

For Windows PowerShell:

$env:JASMINE_SEED=123; jasmine-ts --config="./jasmine.json"

When you use this method, jasmine will use the seed from the environment variable regardless of whether random is set to true or false in your jasmine.json.


内容的提问来源于stack exchange,提问作者pushkin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.11 09:03:06