Monday, 15 February 2021

Jasmine does not like lambda or template literals

I am trying to use Jasmine, via NodeJs to test the javascript in my project. This is in Visual Studio

The Jasmine test looks like

/// <reference path ='../../net5.Ui/wwwroot/Shared/Javascript/helpers.js' />
    
describe('Helpers test', function () {
    it('Test contains', function () {
        const result = helpers.isMatch();
        expect(result).toBe(true);
    });
});

My javascript files all have a similar structure (a singleton approach)

const helper = new function(){
    this.isMatch = function(){ return true; }
}

Visual Studio is able to detect the tests. When I debug, it sadly loads up IE (which may be the problem??) and then I see an error message in Visual Studio

JavaScript critical error at line 25, column 30 in file:///...wwwroot/Shared/Javascript/helpers.js\n\nSCRIPT1014: Invalid character

I navigate to the file and line number/column and note it's the symbol $.
If I remove the $ in the helpers.js file, I get the same error message but for another place - this time for a lambda expression (=>)

I do not know how to fix this... I don't know if the issue is within Visual Studio 2019 or if the issue is within Jasmine

Can some one please suggest a way to fix this? I just want a way to test my Javascript files as part of my CI/CD pipeline



from Jasmine does not like lambda or template literals

No comments:

Post a Comment