-
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
I'm not able to mock s3 with typescript #265
Comments
Hi @victorgsp, if I'm not mistaken the mock lib will still perform parameter validation. You're getting this error because the environment variable |
Hi @thomaux, thanks for the answer. Following your explanation, I put the code below in my test suite:
Now I received the following error: Apparently, my test is using the real aws-sdk instead of the mock. |
@victorgsp it does seem like that yes. Is the full code publicly available so I could have a look? If not, could you maybe share the full files for the source and test? The mock needs to be set before the AWS service is created, from your code snippet that does seem to happen, so I'm unsure where it's going wrong at the moment |
It's not a public repository, but the files are with following content: S3Provider.ts
S3Provider.spec.ts
|
Hmm strange, it works when I copy both those files locally, with the following configuration: package.json {
"name": "sandbox",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@types/jest": "^27.4.0",
"aws-sdk-mock": "^5.6.2",
"jest": "^27.4.7",
"ts-jest": "^27.1.3",
"typescript": "^4.5.5"
}
} jest.config.js module.exports = {
collectCoverage: false,
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '(.*spec.ts)$',
transform: {
'.ts': 'ts-jest',
},
verbose: true,
}; Running
|
Hi guys, i'm not able to mock s3 with typescript
packages version:
my code
my test
Error:
UriParameterError: Expected uri parameter to have length >= 1, but found "" for params.Bucket
`
The text was updated successfully, but these errors were encountered: