-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws mock s3 putObjectTagging "Not Working" ISSUE / Bug #266
Comments
@HanojHanu what are you seeing when you attempt to run this code? (what is the output?) |
Not Mocking my code in Jest using Nodejs
Test suite failed to run
Error [ERR_UNHANDLED_ERROR]: Unhandled error. (NoSuchBucket: The specified bucket does not exist
at Request.extractError (node_modules/aws-sdk/lib/services/s3.js:710:35)
at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12)
at node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:688:12)
at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:116:18) {
code: 'NoSuchBucket',
region: null,
time: 2022-03-24T04:04:56.504Z,
requestId: 'AASKZ3Q97T6P1XCV',
extendedRequestId: 'wId6kZvnmgMk9LIL+Ll2iVGjqKHiaOsLzgDPdzyXnwbN1cY1po1+wGLy7BLWYcDOrcquauHxN/s=',
cfId: undefined,
statusCode: 404,
retryable: false,
retryDelay: 92.723206311658
})
at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:590:14)
at Request.callListeners (node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (node_modules/aws-sdk/lib/request.js:686:14)
at Request.transition (node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (node_modules/aws-sdk/lib/state_machine.js:14:12)
at node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (node_modules/aws-sdk/lib/request.js:38:9) |
@nelsonic Any updates on this issue ? |
@HanojHanu the stack trace you've shared above is for |
Hey @HanojHanu, this might be related to how your actual code is initialised. For example, if S3 is initialised at the top of your module, aws-sdk-mock cannot mock it. Try adding the following to your tests: beforeEach(() => {
// import the aws-sdk after the resetModules, but before each test.
jest.resetModules();
AWSMock.setSDKInstance(require('aws-sdk'));
AWSMock.mock("S3", "putObjectTagging", jest.fn((params, callback) => { // Not working
callback(null, {});
}));
});
afterEach(() => {
AWSMock.restore();
}); |
Thanks @thomaux, I'll try this. I'll update here.. |
tried the same way, what you suggested. @thomaux |
Thanks @HanojHanu that's useful. I'll take some time later this week to take a look at what's going wrong. From the sources I can tell that S3 is being initialised at the top of the file, which is most likely causing the issue. |
Any Fix? |
! important
S3
putObjectTagging
mock not working, why any ideas..... ???look.test.js
package.json
The text was updated successfully, but these errors were encountered: