endpoint not found when testing using Karma, breeze, angular, mocha bardjs

182 Views Asked by At

I am a beginner javascript developer. My first unit test code failed and I want to resolve the problem. The message error is Warned [web-server]: 404: /cash register/product? ERROR: 'Error: NOT FOUND

My unit test code is :

describe("SaveCashregister:", function(done){

    beforeEach(bard.asyncModule('app'));

    describe("#Product", function(){
        it("Add a new Product to the cashregisterDb database", function(done){
            bard.inject(this, '$controller', '$log', '$q', '$rootScope', 'dataservice');
            dataservice
                .getProducts()
                .then(function(data) {
                        expect(data).to.have.length(1);
                    })
                .then(done,done);
        });
    });
});

The getProducts method, I want to test is :

function getProducts()
{
    // http://www.breezejs.com/sites/all/apidocs/classes/EntityManager.html
    var query = breeze.EntityQuery
                .from('produit');               

    //var prodType = manager.getEntityType('Product');
    var products = manager.getEntities('Produit'); 

    return products.length ? 
            util.$q.when(products) : 
                manager.executeQuery(query)
                .then(function(data){
                    logger.log(" codeBar: " + data.results[0].codebar);
                    isReady = true;
                    return data.results;})
    .catch(queryFailed);
}
1

There are 1 best solutions below

0
On

Did you try changing

var products = manager.getEntities('Produit');

to

var products = manager.getEntities('Product');

(I would have rather put a response like this into a comment but my rep isn't high enough.)

If that doesn't fix it can you provide more of the stack-trace?