I’ve been trying to figure out a way to test my lambda functions (with something like Jest), and I’m having a tonne of trouble getting it set up and working. I’m a bit out of my depth, does anyone have any resources that would go over netlify functions testing, or even better, an example project that shows some ways to do it?
I’m pretty sure there is no support for test automation yet. You can do manual testing by running netlify dev in a command line, and then netlify functions:invoke in another.
I’m a noob at serverless myself, but I would recommend for you to setup a server.js in whatever framework you prefer (express, hapi), use a translator like serverless-http, and then test against that server.
You’d indeed have to do a test either on the already-deployed functions, or on a local copy you setup using netlify-lambda serve, @nonissue . The functions aren’t available until AFTER deploy for execution via our CDN.
You may be able to pick up some other associated advice from this article such as workflows for testing deploy previews before merging to production, or using multiple sites (1 for test, publishing later to prod): [Support Guide] Testing your Netlify builds
Seems like it’s worked ok to judge from it working from package.json? netlify-lambda serve does no deploying, it just starts up your functions locally so you can access them on your computer without our infrastructure.
If it doesn’t run from the command line, we’d need more details on what might be going wrong like the actual error messages, you telling us how you have it installed for general usage, etc