Home page Forum Wiki Mail Jabber Devel NIX-FILES

AltLUG Git

Git-repositories of Altai Linux User Group

Add config.requireExpects. Fixes #207 - Add option to require all tests to call expect().
authorScott González <scott.gonzalez@gmail.com>
Wed, 6 Jun 2012 17:06:34 +0000 (13:06 -0400)
committerScott González <scott.gonzalez@gmail.com>
Wed, 6 Jun 2012 17:06:34 +0000 (13:06 -0400)
qunit/qunit.js

index 97d808d..8d2dc9c 100644 (file)
@@ -158,7 +158,9 @@ Test.prototype = {
        },
        finish: function() {
                config.current = this;
-               if ( this.expected != null && this.expected != this.assertions.length ) {
+               if ( config.requireExpects && this.expected == null ) {
+                       QUnit.pushFailure( "Expected number of assertions to be defined, but expect() was not called.", this.stack );
+               } else if ( this.expected != null && this.expected != this.assertions.length ) {
                        QUnit.pushFailure( "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run", this.stack );
                } else if ( this.expected == null && !this.assertions.length ) {
                        QUnit.pushFailure( "Expected at least one assertion, but none were run - call expect(0) to accept zero assertions.", this.stack );
@@ -539,6 +541,9 @@ config = {
        // by default, modify document.title when suite is done
        altertitle: true,
 
+       // when enabled, all tests must call expect()
+       requireExpects: false,
+
        urlConfig: [ "noglobals", "notrycatch" ],
 
        // logging callback queues

Hosting is provided AltSPAHow to use Git
Please direct any questions on jabber alex.wolf@jabber.ru

Valid HTML 4.0 Transitional Valid CSS!

Designer Alexander Wolf