Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatched "suiteEnd" event when a filter is applied #1416

Closed
step2yeung opened this issue Nov 19, 2019 · 0 comments
Closed

Mismatched "suiteEnd" event when a filter is applied #1416

step2yeung opened this issue Nov 19, 2019 · 0 comments
Assignees
Labels
Component: Core For module, test, hooks, and reporters. Type: Bug Something isn't working right.

Comments

@step2yeung
Copy link
Contributor

step2yeung commented Nov 19, 2019

Tell us about your runtime:

  • QUnit version: 2.9.4-pre
  • What environment are you running QUnit in? (e.g., browser, Node): browser
  • How are you running QUnit? (e.g., script, testem, Grunt): grunt

What are you trying to do?

Code that reproduces the problem:

  1. git clone qunit & yarn dev
  2. Add the following code to dist/qunit.js
    a. console.logs after function runLoggingCallbacks(key, args) {
function runLoggingCallbacks(key, args) {
    console.log('runLoggingCallbacks called for '+key)
    var callbacks = config.callbacks[key];

b. console.logs before if (module.testsRun === numberOfTests(module)) {

}).then(function () {
    console.log('module.testsRun === numberOfTests(module)');
    console.log(module.testsRun +' === ' +numberOfTests(module))
    if (module.testsRun === numberOfTests(module)) {
        var completedModules = [module];
  1. Point a browser to http://localhost:8000/test/string-filter.html
  2. Open up browser console

If you have any relevant configuration information, please include that here:

What did you expect to happen?

Expected moduleDone callback (from the suiteEnd event) to be called.

What actually happened?

moduleDone was not called because module.testsRun does not equal numberOfTests(module)
1 of the 3 test was filtered out and not ran. Leaving only 2 test to be ran.
So module.testsRun = 2 while numberOfTests(module) = 3

Screen Shot 2019-11-19 at 9 09 58 AM

Regardless, I believe moduleDone should still be called.

@Krinkle Krinkle added Type: Bug Something isn't working right. Component: Core For module, test, hooks, and reporters. labels Jun 19, 2020
@Krinkle Krinkle self-assigned this Aug 24, 2020
@Krinkle Krinkle changed the title moduleDone not called when filter is applied Mismatched "suiteEnd" event when a filter is applied Aug 24, 2020
Krinkle pushed a commit that referenced this issue Aug 26, 2020
…filters

Previously, the `suiteEnd` event and the `moduleDone` callback
were fired when we've run all the tests, based on counting the
number of registered tests in a module and the number of tests
actually run.

This logic does not hold up when there are active module/test filters
used in the runner, because then some of the registered tests will
never run.

The added tests demonstrate the issue, as they will fail without
the src patch. Several of the `suiteEnd` events would not fire.

The impact of this bug was that the `suiteEnd` event and `moduleDone`
callback don't fire if there were active filters such as `--filters`
in the CLI or via the "Filter" field in the HTML Reporter.

This in turn meant that reporters such as TAP would sometimes
reflect the structure of the test suite in an odd way due to
it sometimes missing an "end" event for a group of tests.

Fixes #1416.
Closes #1417.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Core For module, test, hooks, and reporters. Type: Bug Something isn't working right.
Development

Successfully merging a pull request may close this issue.

2 participants