Created
June 12, 2020 23:38
-
-
Save jrichardsz/6355b90cc4d673d1269f7180ce70a0f8 to your computer and use it in GitHub Desktop.
test nodejs snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var path = require('path'); | |
global.imports = function importFunction(relativeModuleLocation) { | |
let paths = require.main.filename.split("node_modules") | |
return require(paths[0]+"src/main"+relativeModuleLocation); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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