5
The plugin serverless-offline is used to start a framework-based application Serverless. To start, the command is used serverless offline [options]
or sls offline [options]
Is it possible to start it through Javascript? Something like:
const slsOffline = require('serverless-offline');
slsOffline.start(options)
.then(() => {/* ... */});
Reason: testing the code. In the documentation it is suggested to test handlers directly, but this may pass errors in the serverless.yml
, how to write the route name, parameter or method incorrectly, or even forget to create the route after creating Handler
I tried to run the command that starts the application and runs the tests together:
npm run start && npm run test
However, as the start
If it keeps running until it is stopped and the application stops, the tests are never run or run after the application has stopped. Running scripts on different terminals is complicated to automate development and deployment processes, such as using Bitbucket Pipeline to run build, test and deploy
It is in English but I believe this site can help https://serverless-stack.com/chapters/serverless-nodejs-starter.html
– user181003
This might help you: https://github.com/dherault/serverless-offline#Usage-with-invoke
– Luiz Felipe