I'm running a single unit test in firebase/functions with jasmine via the cli :
import {} from 'jasmine';
import { httpHelloWorldFunction } from './http.js';
describe('functions/core/functions/http', () => {
it('send to be called with "hello from Firebase"', () => {
const req = { data: { foo: 'world' } };
const res = { send: (s) => {} };
spyOn(res, 'send').and.callThrough();
httpHelloWorldFunction(req, res);
expect(res.send).toHaveBeenCalledWith("Hello from Firebase!");
});
});
Target code is this :
import * as functions from "firebase-functions";
export function httpHelloWorldFunction(request, response) {
response.send("Hello from Firebase!");
};
The test runs and passes without issue if I run it via the CLI. However I've encountered two issues with trying to run it via the Jasmine Test Explorer dashboard.
Issue 1: the Jasmine Log emits a JSON token error when trying to parse process.argv[5] (which is undefined), error here :
/home/todd/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.2/out/worker/loadTests.js:12
logEnabled = JSON.parse(process.argv[5]);
^
SyntaxError: Unexpected token u in JSON at position 0
at JSON.parse (<anonymous>)
at Object.<anonymous> (/home/todd/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.2/out/worker/loadTests.js:12:23)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .js] (/home/todd/Dev/resell-it-1/functions/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
Issue 2: I modified loadTests.ts to set logEnabled to true and then encountered this error in the Test Explorer Log:
/home/todd/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.2/out/worker/loadTests.js:15
const jasmine = new Jasmine({});
^
TypeError: Jasmine is not a constructor
at Object.<anonymous> (/home/todd/.vscode/extensions/hbenl.vscode-jasmine-test-adapter-1.8.2/out/worker/loadTests.js:15:21)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Object.require.extensions.<computed> [as .js] (/home/todd/Dev/resell-it-1/functions/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
Due to the file structure (all target and test code under the functions folder), I've had to configure my settings json as so:
I'm running a single unit test in firebase/functions with jasmine via the cli :
Target code is this :
The test runs and passes without issue if I run it via the CLI. However I've encountered two issues with trying to run it via the Jasmine Test Explorer dashboard.
Issue 1: the Jasmine Log emits a JSON token error when trying to parse process.argv[5] (which is undefined), error here :
Issue 2: I modified loadTests.ts to set logEnabled to true and then encountered this error in the Test Explorer Log:
Due to the file structure (all target and test code under the functions folder), I've had to configure my settings json as so:
And here are my launch.json and jasmine.json files:
And my tsconfig file:
Any ideas? Thanks :-)