Skip to content

Instantly share code, notes, and snippets.

@jrichardsz
Created June 12, 2020 23:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrichardsz/6355b90cc4d673d1269f7180ce70a0f8 to your computer and use it in GitHub Desktop.
Save jrichardsz/6355b90cc4d673d1269f7180ce70a0f8 to your computer and use it in GitHub Desktop.
test nodejs snippet
var path = require('path');
global.imports = function importFunction(relativeModuleLocation) {
let paths = require.main.filename.split("node_modules")
return require(paths[0]+"src/main"+relativeModuleLocation);
}
require('../NodeHelper.js');
// start a mock of /settings.json
const assert = require('assert');
const GeofrontendClient = imports("/client/GeofrontendClient.js");
var client = new GeofrontendClient();
describe('/settings.json', () => {
it('should return status 200', async () => {
await client.getSettings("http://localhost:5000/geofrontend","/settings.json").then(function(response) {
assert.equal(200, response.data.status);
assert(response.data.content.session.tokenV1)
assert(response.data.content.session.tokenV2)
})
});
});
//https://medium.com/serverlessguru/how-to-unit-test-with-nodejs-76967019ba56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment