Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function setupResponseMock() {
const responseMock = stubExpressContext();
response = responseMock.response;
observedResponse = responseMock.result;
// content-type should be undefined since it's not set in the response yet.
expect(response.getHeader('content-type')).to.eql(undefined);
}
});
function givenRequest(options?: ShotRequestOptions): Request {
return stubExpressContext(options).request;
}
function givenStubbedContext() {
contextStub = stubExpressContext();
}
});
function givenRequest(options?: ShotRequestOptions): Request {
return stubExpressContext(options).request;
}
}
}
class CustomLogger implements Provider {
value() {
return (err: Error, statusCode: number, request: Request) => {
lastLog = `${request.url} ${statusCode} ${err.message}`;
};
}
}
const app = new Application();
app.component(CustomRestComponent);
const server = await app.getServer(RestServer);
const logError = await server.get(SequenceActions.LOG_ERROR);
const expressContext = stubExpressContext({url: '/'});
logError(new Error('test-error'), 400, expressContext.request);
expect(lastLog).to.equal('/ 400 test-error');
});
});