Feature request: Run Node tests as part of sam build
- Dominant language
- Python
- Stars
- 6.7k
- Forks
- 1.2k
- Avg merge
- 1d 10h
- Merged PRs (30d)
- 52
Description
### Describe your idea/feature/enhancement
The `sam build` command should run tests as well for Node runtime, just like it does for Java runtime.
### Proposal
Include one more step below in the npm builder to run any available tests. One way to do this is to include a step that runs `npm run test` command, which will eventually run the command as specified in the `package.json`.
```
~ sam build
Starting Build use cache
Manifest file is changed (new hash: 64859513bdbd90c2fad6e086b18218ab) or dependency folder (.aws-sam/deps/6b249e35-3277-4962-a9f6-31718d68bd22) is
missing for (HelloWorldFunction), downloading dependencies and copying/building source
Building codeuri: /Users/kush.saraiya/Documents/Workspace/Personal/sample-sam-app/hello-world runtime: nodejs20.x metadata: {} architecture: x86_64
functions: HelloWorldFunction
Running NodejsNpmBuilder:NpmPack
Running NodejsNpmBuilder:CopyNpmrcAndLockfile
Running NodejsNpmBuilder:CopySource
Running NodejsNpmBuilder:NpmInstall
Running NodejsNpmBuilder:CleanUp
Running NodejsNpmBuilder:CopyDependencies
Running NodejsNpmBuilder:CleanUpNpmrc
Running NodejsNpmBuilder:LockfileCleanUp
Running NodejsNpmBuilder:LockfileCleanUp
Build Succeeded
```
Things to consider:
1. Will this require any updates to the [SAM Spec](https://github.com/awslabs/serverless-application-model) - No
### Additional Details
I came across this limitation where I was maintaining two SAM projects - one with Java and one with Node. We used `sam build` in our pipeline for both of them and I noticed that the sam build command ran the Java unit tests but not for Node. I think this will be a great feature to be added.
I am very much interested to work on this feature and can open a PR if you think this is worth it.
Contributor guide
Assessment
This issue has not been assessed yet.