How can I do a Unit Testing in KnockoutJS with QUnit

16 Views Asked by At

I have this ViewModel (short) with KnockoutJS and I need to make a Unit Test using QUnit but I have this error message when i running my test.

ViewModel:

var modeloContratacion;//NOSONAR

define(['jquery', 'compartidas'], function($, compartidas) {

    var _modeloContratacion = function() {

    this.ObtenerPopUpARC = function(){
            const dfdPopUp = $.Deferred();

            const _resAccesoServicioObtenerPopUpARC =
            compartidas.InvocarServicio(this.Configuracion.RutaServicioCentral() + 'catalogos/obten-popup', '', 'GET', '');

            _resAccesoServicioObtenerPopUpARC.done(function(jsonR){
                dfdPopUp.resolve(jsonR);
            });

            return dfdPopUp.promise();
        };
 };

    modeloContratacion = new _modeloContratacion();
    return modeloContratacion;
});

Unit Test:

const modeloContratacion = require('../src/main/webapp/Models/ModeloContratacion.js');

QUnit.module('modeloContratacion');

QUnit.test('Mensaje PopUp', function (assert) {
    return modeloContratacion.ObtenerPopUpARC().then(function (result) {
        assert.equal(result.control.codigoRespuesta, 0);
    });
});

Error Message

What i can do? Or can i use another framework to do Unit Test?

I'm trying to do a Unit Test

0

There are 0 best solutions below