I am using aws-sdk-mock with Jest for testing AWS Lamda.
My lambda uses AWS Polly Service to convert text to speech. Following is the piece of code which I want to mock as well as do parameter validation.
var task = await polly.startSpeechSynthesisTask({
OutputFormat: "mp3",
Text: fullTextSSML,
TextType: "ssml",
Engine: audioProfile.engine,
VoiceId: audioProfile.voice,
OutputS3KeyPrefix: `${orgId}/${integrationId}/fa`,
OutputS3BucketName: process.env.AUDIO_BUCKET,
SnsTopicArn: process.env.POLLY_TASK_COMPLETED_SNS_TOPIC_ARN
}).promise();
I have written a mock as follow.
AWS.mock('Polly', 'startSpeechSynthesisTask', ()=>{
return {
SynthesisTask:{
TaskId: "0a4a503d-8be8-46a6-a638-1621d3405fb0"
}
}
});
How do I mock this service as well as do parameter validation at the same time?