Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ReferenceError: notOk is not defined

I use QUnit for JavaScript unit testing, have quite a few tests already. Majority of them uses assert in the way:

ok(condition.isTrue());

These tests are run well by Visual Studio embeded tests system (in the "Test Explorer") and by 'external' QUnit engine (which is called by clicking 'QUnit test (click to run)' context menu that is displayed if you hit circle left to the QUnit test).

But if I use assert in another way:

notOk(condition.isFalse());

Then tests are run well only inside of Visual Studio tests system, while attempt to run tests by QUnit give following error:

Died on test #1     at http://localhost:64720/Tests.js:123:1: notOk is not defined
Source:     
ReferenceError: notOk is not defined
    at Object.<anonymous> (http://localhost:64720/Tests.js:129:5)
    at Object.Test.run (http://localhost:64720/qunit.js:790:18)
    at http://localhost:64720/qunit.js:877:10
    at process (http://localhost:64720/qunit.js:593:24)
    at http://localhost:64720/qunit.js:182:5

Why does this happen and how to make "notOk" running properly by QUnit?

Thank you.

like image 416
Budda Avatar asked Oct 08 '15 02:10

Budda


1 Answers

Are you facing the same problem as here: 'equal' is not defined : Ember-qunit does not seem to be importing ?

The solution is to use notOk through assert like this:

test('it is not ok', function(assert) {
   var some_value = false;
   assert.notOk(some_value);
});
like image 199
mico Avatar answered Oct 13 '22 02:10

mico