-
Notifications
You must be signed in to change notification settings - Fork 51
Description
Hello,
First off, thank you very much for this plugin. Makes TS serverless development with Jest very much easier. I may have an interesting corner case to bring up, though hopefully this is something simple I am doing wrong.
This all started with trying to hook a programmatic infrastructure update into the CloudFormation stack update on serverless deploy
using a CFN custom resource. Worked great for the initial custom resource creation, but I wanted the update to run on subsequent deploys as well. Which lead me here:
Following the excellent suggestion here:
serverless/serverless#4483 (comment)
Using serverless file variables:
I was able to get the updates running on every serverless deploy
, which works well for the continuous development environment we are setting up with this new project. Architecture validated, time to cover with testing!
I setup a Jest test like so:
import jestPlugin from 'serverless-jest-plugin';
import * as mod from '../myCustomResource';
const { lambdaWrapper } = jestPlugin;
const wrapped = lambdaWrapper.wrap(mod, { handler: 'handler' });
...
const response = await wrapped.run({});
However, when running in the serverless-jest-plugin
environment, I am getting an error:
● Test suite failed to run
Cannot find module 'uuid/v4'
> 1 | module.exports = () => require('uuid/v4')();
Which seems to be caused by this line in the serverless.yml
:
UUID: ${file(./uuid.js)}
This error seems to be isolated to the serverless-jest-plugin
environment, since it is working w/o error when running serverless deploy
.
Please advise,
-- Tim