jasmine / jasmine-browser-runner

Serve and run your Jasmine specs in a browser
50 stars 25 forks source link

random: false has no effect to "serve" task (options ignored) #12

Closed magynhard closed 2 years ago

magynhard commented 2 years ago

When running

npx jasmine-browser-runner serve --verbose --no-random

and using the following configuration at spec/support/jasmine-browser.json:

{
  "srcDir": ".",
  "srcFiles": [
    "src/**/*.?(m)js",
  ],
  "specDir": "spec",
  "specFiles": [
    "**/*[Ss]pec.?(m)js"
  ],
  "helpers": [
    "helpers/**/*.?(m)js"
  ],
  "random": false,
  "browser": "headlessChrome"
}

I get the following output:

$ npx jasmine-browser-runner serve --verbose --no-random
Jasmine server is running here: http://localhost:8888
Jasmine tests are here:         /home/me/project/spec
Source files are here:          /home/me/project/src

The option random: false has no effect.

I expect, that the URI in line 2 should include the option as parameter:

Jasmine server is running here: http://localhost:8888/?random=false

And I expect the same behaviour for the other options as well, if set.

Otherwise i always have to add that parameter manually, before opening the URI inside the browser.

sgravrock commented 2 years ago

If you're trying to turn randomization off permanently, you can add "env": { "random": false } to your config file. (The README and the getting started page said to use "random": true until about 5 minutes ago. That was a mistake.) If you're only trying to turn it off for a single interactive run, the supported way to do that is indeed to manipulate the URL either manually or using the options UI on the spec runner HTML page.

Note that there's only a little bit of overlap between the options supported by the serve and runSpecs subcommands, and neither of them supports --verbose:

% npx jasmine-browser-runner help  

Usage: jasmine-browser <command> [options]

Commands:
  help, -h     show help
  version, -v  show versions for this and jasmine-core
  init         initialize a new Jasmine project
  serve        start a server with your Jasmine specs
  runSpecs     start a server and run your Jasmine specs in a browser

Subcommand options:

  init
    --esm  configure for use with ES modules (<script type="module">)

  serve
    --config=<value>  path to the config file
    --port=<value>    port to run the server on

  runSpecs
    --config=<value>    path to the config file
    --port=<value>      port to run the server on
    --[no-]color        turn on or off color output
    --filter=<value>    filter specs to run only those that match the given
                        string
    --fail-fast         stop Jasmine execution on the first failure
    --[no-]random       turn on or off randomization
    --seed=<value>      specify a seed for randomization
    --reporter=<value>  path to reporter to use instead of the default Jasmine
                        reporter
    --browser=<value>   which local browser to launch
magynhard commented 2 years ago

Thank you for your reply.

Your commit https://github.com/jasmine/jasmine-browser-runner/commit/763ffc8a9b11e9aa621eb9bfe9709a1527f8bc89 helped me to solve my problem by using

# package.json
{

  ...

  "env": {
    "random": false
  }
}

which affects runSpecs and serve as well. So random run is even is disabled without any URL parameter on serve and i can just click the link and run the tests without an initial unwanted random run.

Not having the --[no]-random parameter flag for serve could lead many developers to the false assumption that the random option is generally not available for serve at all. So you might consider adding it there.

But for me ... I'm happy now with the correct configuration!

Thank you!