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

QUnit.todo() with a failure are reported as failling #111

Open
hashar opened this issue Jun 26, 2018 · 1 comment
Open

QUnit.todo() with a failure are reported as failling #111

hashar opened this issue Jun 26, 2018 · 1 comment

Comments

@hashar
Copy link

hashar commented Jun 26, 2018

I had the use case of a test being properly implemented but the feature code being incomplete and failing. When running the tests with the QUnit web interface, the test is not erroring out and is properly labeled todo.

qunit_todo_is_ok_on_web

However when running karma, the test is wrongfully reported as failing:

SUMMARY:
✖ 1 test failed

FAILED TESTS:
  ext.graph.visualEditor
    ✖ ve.ui.TableWidget
      Chrome 66.0.3359 (Linux 0.0.0)
    Died on test #4     at 
....
    TypeError: Cannot read property '0' of undefined
        at VeUiTableWidget.ve.ui.TableWidget.onInsertColumn   // expected failure
...
        at runTest (node_modules/qunit/qunit/qunit.js:1530:30)
        at Test.run (node_modules/qunit/qunit/qunit.js:1516:6)
        at node_modules/qunit/qunit/qunit.js:1728:12
        at advanceTaskQueue (node_modules/qunit/qunit/qunit.js:1129:6)
        at advance (node_modules/qunit/qunit/qunit.js:1110:4)

In lib/adapter.js I adjusted runner.testDone to print the test and testResult to the console which yields:

LOG: Object{
  name: 've.ui.TableWidget',
  module: 'ext.graph.visualEditor',
  skipped: false,
  todo: true,
  failed: 1,
  passed: 3,
  total: 4,
LOG: Object{success: false, errors: ['Died on test #4 ...

The testResult is set by runner.log which mark it with success = false. However in runner.testDone, the todo flag should be used to invert the result. Potentially:

--- orig.js	2018-06-26 22:31:26.880087441 +0200
+++ new.js	2018-06-26 22:32:36.218186993 +0200
@@ -8,6 +8,11 @@
 		time: new Date().getTime() - timer
 	}
 
+	// For QUnit.todo(): flip success report
+	if ( test.todo === true ) {
+		result.success = !testResult.success
+	}
+
 	if (result.description.indexOf('global failure') !== -1) {
 		return
 	}

Environment:

  • karma 2.0.2
  • karma-qunit 2.0.1
  • qunit 2.6.0
@hashar
Copy link
Author

hashar commented Jun 26, 2018

From a discussion I had with @Krinkle , it is left to determine whether QUnit itself should handle the todo flag and flip the success or whether it should be handled by the reporter.

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

No branches or pull requests

2 participants