Skip to content
This repository has been archived by the owner on Dec 28, 2023. It is now read-only.

Delay __karma__.start() until es6 test modules have been loaded #207

Closed
dwt opened this issue Sep 27, 2018 · 1 comment
Closed

Delay __karma__.start() until es6 test modules have been loaded #207

dwt opened this issue Sep 27, 2018 · 1 comment

Comments

@dwt
Copy link

dwt commented Sep 27, 2018

If unit tests are loaded from modules (which is supported via the files configuration option) then __karma__.start() should really be delayed until after all the modules have been loaded, to give unit tests the ability to load before the start event.

I'm not sure about all test frameworks, but at least for jasmine it is necessary, as you cannot add tests to it, after it has started executing all it's configured tests.

So with a configuration like this:

    files: [
      { pattern: 'static/vendor/**/*.js', watched: false },
      { pattern: 'static/*.js', type: 'module', included: false },
      { pattern: 'static/tests/*.js', type: 'module' },
    ],

I would really like the context.html to read

  <script type="module">
    window.__karma__.loaded();
  </script>
  <script nomodule type="text/javascript">
    alert("your browser doesn't support modules, use a different one")
  </script>

instead of

  <script type="text/javascript">
    window.__karma__.loaded();
  </script>

which it is currently executing.

Not quite sure what the best way to patch this in would be, but it seems to work great for me in local tests.

So: are there any downsides to this approach? How would you be willing to take this as a pull request?

@dwt dwt changed the title Delay __karma__.start() until test modules have been loaded Delay __karma__.start() until es6 test modules have been loaded Sep 27, 2018
@dwt
Copy link
Author

dwt commented Sep 28, 2018

Hm, I just realized that this is the wrong project to report this. Moving it now.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant