Open cSchubes opened 6 years ago
I'm having a similar problem with the EC2 service. I have tests using version 1.7.0
that works but the latest does not.
I'm having the same issue :(
same here unfortunately
Same here, are there any workarounds other than calling remock
subsequent times?
I noticed the issue went away when running tests serially.
Hi!
I had the same issue with s3 + restore function, so this was my workaround:
const AWS = require('aws-sdk');
// Environment
const { AWS_REGION } = process.env;
AWS.config.update({ region: AWS_REGION });
const deleteModule = module => delete require.cache[require.resolve(module)];
const requireUncached = module => {
deleteModule(module);
return require(module);
};
describe('some tests', async () => {
let AWSMock;
beforeEach(async () => {
AWSMock = requireUncached('aws-sdk-mock');
AWSMock.setSDKInstance(AWS);
});
after(async () => {
deleteModule('aws-sdk-mock');
});
afterEach(async () => {
AWSMock.restore();
});
...
In my case I have been working with DynamoDB. To restore command works I have called this way: AWSMock.restore('DynamoDB.DocumentClient') instead of AWSMock.restore('DynamoDB');
Hi all,
I am attempting to mock an S3 getObject call, but I need it to be mocked differently in different tests. This problem is discussed in other issues and I have organized my tests in the way those issues recommend. Specifically, I:
setSDKInstance(AWS_SDK)
AWS.mock
at the beginning of each test.The restore call is where things are going wrong. I went and added some logging statements to index.js in the aws-sdk-mock package to see what was happening, and the function is definitely doing the right things - but for some reason the subsequent test will use the previous s3 mock. Example test suite is below. Any help is greatly appreciated!!