I have read this article
https://community.apigee.com/articles/3964/unit-testing-javascript-code-with-mocha-sinon-and.html
like the one from the article for example
try { var responseCode = parseInt(context.getVariable('response.status.code')); var log = { org: context.getVariable('organization.name'), env: context.getVariable('environment.name'), responseCode: responseCode, isError: (responseCode >= 400) }; if (log.isError) { log.errorMessage = context.getVariable('flow.error.message'); } var logglyRequest = new Request( 'https://loggly.com/aaa', 'POST', {'Content-Type': 'application/json'}, JSON.stringify(log) ); httpClient.send(logglyRequest); } catch (e) {}
The thing is that when I try to 'require' the js file I get nothing.
And only when I add 'module.exports' I get the file.
1. Am I not importing this the right way?
2. The problem is that apigee js object model doesn't recognize 'module.exports' so I cant leave it that way. what should I do?