I am using node js in VS 2019. I want to try Mocha as the test platform so I have gone through and installed that and got it working in a basic sense. I have a simple calculator node js file (calc.js).
I have another file that has basic hello world tests (basictest.js). If I do NOT put in the "require" line for Calc.js, then these tests (Test 1 and Test 2) are discovered by VS 2019 test explorer and are listed.
However, I need the require line to access the calculator app, so when I put the require line var mycalc = require('./Scripts/Calc.js'); in there, the tests are NOT discovered. The same thing happens if I try a reference path=.. to it. I am new to node js so I could be missing something seemingly obvious as well when referencing functions in another js file.
basictest.js:
'use strict';
var assert = require('assert');
var mycalc = require('./Scripts/Calc.js');
describe('Test Suite 1', function () {
it('Test 1', function () {
assert.ok(true, "This shouldn't fail");
});
it('Test 2', function () {
assert.ok(1 === 1, "This shouldn't fail");
assert.ok(false, "This should fail");
});
});