qunitjs / qunit

🔮 An easy-to-use JavaScript unit testing framework.
https://qunitjs.com
MIT License
4.02k stars 784 forks source link

CLI --seed without value and files argument is counterintuitive #1691

Closed Krinkle closed 6 days ago

Krinkle commented 2 years ago
Usage: qunit [options] [files]

[…]

Options:
  --seed [value]         specify a seed to re-order your tests;
                         if specified without a value, a seed will be generated
  […]

When using qunit --seed it will default to running test/**.js and will print the randomly selected seed for future re-use. This works as expected:

$ qunit --seed
Running tests with seed: 3vjdr2nhlga
TAP version 13
ok 1 Single > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0

The problem is, when using a files argument, the command becomes ambiguous and it naturally becomes the value for the seed instead:

$ qunit --seed test/single.js
Running tests with seed: test/single.js
[…]

This can be worked around currently by using -- to mark the end of the options and the start of the arguments:

$ qunit --seed -- test/single.js 
Running tests with seed: 3vjdr2nhlga
TAP version 13
ok 1 Single > has a test
1..1
# pass 1
# skip 0
# todo 0
# fail 0
Krinkle commented 3 weeks ago

Strawman proposal:

Alternatives I considered: