Jasmine does not let me reference a function with <reference path

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();

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

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

Visual Studio is able to detect the tests.

Node version 14.15.4


(I have stripped some context as it’s no longer valuable)

I ran from command line as requested in comments. It gives:

Test Suite 1 Test 1
 ReferenceError: helpers is not defined
 ReferenceError: helpers is not defined
    at UserContext.<anonymous> (H:\GitHub\path\nodejs.TestJs\Tests\UnitTest1Spec.js:7:24)
    at <Jasmine>
    at processImmediate (node:internal/timers:463:21)

Frustratingly, this website shows what I am trying to do and I don’t see how it is different to what I am doing

/// <reference path=""../application.js"">
describe("App", function () {
    describe("foo", function () {
        it("should return bar", function () {

and the javascript

var App = {
    foo: function() {
        return "bar123";

Leave a Comment