I would want to moc the call function the call to s3.listObjectV2.
I am only in need of the contents of what's returned.
public async init() {
AWS.config.update({
region: config.aws.region,
})
const s3 = new AWS.S3({ apiVersion: config.aws.S3.apiVersion })
let params = { Bucket: config.aws.S3.ctrPredictorModelBucket }
const data = await s3.listObjectsV2(params).promise()
return data.contents
}
Then in the test, I would want to do before every test something like
before( () => {
s3 = mock.mock(AWS.S3)
// request = mock.mock(AWS.Request)
mock.when(s3.listObjectsV2(mock.anything()).thenReturn(Return_object))
})
with Return_objecy only contains what is needed.
But the current way things are set I get an error saying the s3.listObjectsV2 is not a function