Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: karma-runner/karma
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v6.3.8
Choose a base ref
...
head repository: karma-runner/karma
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v6.3.9
Choose a head ref
  • 4 commits
  • 10 files changed
  • 3 contributors

Commits on Nov 11, 2021

  1. style: fix grammar error in browser capture log message

    Fixes a grammar error in the log message when a browser does not capture in time.
    
    Fixes #3716
    stefan-becking-webcom authored and Jonathan Ginsburg committed Nov 11, 2021
    Configuration menu
    Copy the full SHA
    b153355 View commit details
    Browse the repository at this point in the history

Commits on Nov 16, 2021

  1. fix: restartOnFileChange option not restarting the test run

    The problem was caused by a race condition in the client JS implementation. When the `restartOnFileChange` option is enabled, the server would send [two commands](https://github.com/karma-runner/karma/blob/b153355de7e05559d877a625c9b0c5d23a3548bd/lib/server.js#L377) to the browser: `stop` and `execute`. Both of these commands navigate the context. `stop` navigates to the blank page, while `execute` navigate to the `context.html` thus triggering a test run. The `execute` command would trigger the navigation synchronously, but the `stop` command would trigger it on the next event loop tick. As a result, if both commands arrive almost at the same time, their order is effectively reversed: first schedule new execution and then immediately stop it. The bug is resolved by handling both commands synchronously thus ensuring correct order.
    
    The setTimeout() call in question was introduced in 15d80f4 to solve #27 and was retained over time. It's not completely clear why the timeout was added, but it does not seem to be relevant.
    
    With `clearContext: true`, karma will reset the context and thus cancel any scheduled navigations as soon as the test framework has reported the `complete` event. As navigations are canceled they don't affect karma and thus karma does not care about them. It's true that the user may have a test with race conditions (e.g. missing `done` callback), but it is up to them to investigate and fix it.
    
    With `clearContext: false`, the same logic applies, that karma does not care about navigations after `complete` event as long as they don't break karma itself. Here it gets a bit tricky:
    
    - Navigation within the same origin is undesired, but it doesn't break karma and the next execution can proceed normally.
    - Navigation to a different origin however is a problem as after such navigation the iframe becomes cross-origin and karma client will not be able to navigate it to the `context.html` or interact with it at all for that matter until the page reload (see [this SO answer](https://stackoverflow.com/q/25098021/1377864)). This will break the watch mode, but IMO we can let it be given that the case is quite uncommon, the user will see the browser window displaying something unexpected and the error in the CLI output. The changes in this commit don't make this case any worse and it does not seem to be possible to prevent such problematic navigations with the current state of browsers per https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload:
    
    > To combat unwanted pop-ups, some browsers don't display prompts created in beforeunload event handlers unless the page has been interacted with. Moreover, some don't display them at all.
    
    Fixes #3724
    devoto13 authored and Jonathan Ginsburg committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    92ffe60 View commit details
    Browse the repository at this point in the history
  2. test: add test case for restarting test run on file change

    devoto13 authored and Jonathan Ginsburg committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    cf318e5 View commit details
    Browse the repository at this point in the history
  3. chore(release): 6.3.9 [skip ci]

    ## [6.3.9](v6.3.8...v6.3.9) (2021-11-16)
    
    ### Bug Fixes
    
    * restartOnFileChange option not restarting the test run ([92ffe60](92ffe60)), closes [#27](#27) [#3724](#3724)
    semantic-release-bot committed Nov 16, 2021
    Configuration menu
    Copy the full SHA
    b8eafe9 View commit details
    Browse the repository at this point in the history
Loading