serverless-jest-plugin | Serverless Framework which adds support | Serverless library
kandi X-RAY | serverless-jest-plugin Summary
kandi X-RAY | serverless-jest-plugin Summary
This plugins does the following:.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of serverless-jest-plugin
serverless-jest-plugin Key Features
serverless-jest-plugin Examples and Code Snippets
Community Discussions
Trending Discussions on serverless-jest-plugin
QUESTION
I am kicking off a new project with a new Serverless TypeScript monorepo! Used the aws-nodejs-typescript
template, which gave a serverless.ts
config file. After some weeks, I am now getting the nice warning below from Serverless on command line:
ANSWER
Answered 2020-Nov-04 at 21:41It is really simple to apply this change, all what you need to do is to add this to your serverless.yml file.
QUESTION
I am using the serverless framework for running lambda functions on AWS.
In my serverless.yml
there are environment variables that are fetched from SSM.
When I write integration tests for the code, I need the code to have the environment variables and I can't find a good way to do this.
I don't want to duplicate all the variables definitions just for the tests, they are already defined in the serverless.yml. Also, some are secrets and I can't commit them to source conrol, so I would have to also repeat them in the ci environment.
Tried using the serverless-jest-plugin
but it is not working and not well maintained.
Ideas I had for solutions:
- Make the tests exec
sls invoke
- this will work but would mean that the code cannot be debugged, I won't know the test coverage, and it will be slow. - Parse the
serverless.yml
myself and export the env variables - possible but rewriting the logic of pulling the SSM variables just for tests seems wrong.
Any ideas?
...ANSWER
Answered 2018-Nov-09 at 22:12Are you looking to do mocked unit tests, or something more like integration tests?
In the first case, you don't need real values for the environment variables. Mock your database, or whatever requires environment variables set. This is actually the preferable way because the tests will run super quickly with proper mocks.
If you are actually looking to go with end-to-end/integration kind of approach, then you would do something like sls invoke
, but from jest using javascript. So, like regular network calls to your deployed api.
Also, I would recommend not to store keys in serverless.yml
. Try the secret: ${env:MY_SECRET}
syntax instead (https://serverless.com/framework/docs/providers/aws/guide/variables#referencing-environment-variables), and use environment variables instead. If you have a ci/cd build server, you can store your secrets there.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install serverless-jest-plugin
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page