This document provides guidelines for running unit and integration tests.
Unit tests run without external dependencies and are located in each package's test directory.
Integration tests require a predefined AWS, Serverless Dashboard, and Terraform Cloud setup. They run in CI only.
npm test -w @serverlessinc/sf-coreYou can run specific test suites using scripts from packages/sf-core/package.json. For example:
npm run test:resolvers -w @serverlessinc/sf-coreThe following environment variables need to be set before running the tests:
export SERVERLESS_LICENSE_KEY_DEV="your-license-key"
export SERVERLESS_ACCESS_KEY_DEV="your-access-key"The integration tests require specific AWS resources, including:
/resolvers/sample-param(String):ssm-value/resolvers/sample-secure-param(SecureString):ssm-value/resolvers/sample-list-param(StringList):foo,bar/resolvers/sample-json-param(SecureString):{ "foo": "bar" }/resolvers/object-secure-param(SecureString):{ "objectKey": "objectValue" }/serverless-framework/license-key-serverlesstestaccount(SecureString):your-license-key/resolvers/terraform-hcp-token(String):your-terraform-hcp-token
/resolvers/sample-param(String):ssm-value/resolvers/sample-secure-param-eu-west-1(SecureString):ssm-value
resolvers/sample-secret:
{
"num": 1,
"str": "secret",
"arr": [true, false]
}serverless-compose-state-bucket-integration-test- Versioning enabled
terraform-s3-resolver-test-bucket- Versioning enabled
resolvers-integration-test- File:
test.txt - Content:
file content
- File:
terraform-s3-resolver-test-lock-table- Primary Key:
LockID(String)
- Primary Key:
sfc-nodejs-resolvers-integration-testServerlessDeploymentBucketName:sfc-nodejs-resolvers-inte-serverlessdeploymentbuck-6vskiu5gzt1uFunction1LambdaFunctionQualifiedArn:arn:aws:lambda:us-east-1:762003938904:function:sfc-nodejs-resolvers-integration-test-function1:1
sfc-nodejs-resolvers-integration-testServerlessDeploymentBucketName:sfc-nodejs-resolvers-inte-serverlessdeploymentbuck-vky0nzemsvvrFunction1LambdaFunctionQualifiedArn:arn:aws:lambda:eu-west-1:762003938904:function:sfc-nodejs-resolvers-integration-test-function1:1
- Dashboard Parameters
dashboard-param:dashboard-value
- Dashboard Outputs
outputs:
str: string-value
num: 42
obj:
foo: barserverlesstestaccountorganizationserverless-test-01workspace
For any issues, refer to the tests/integration/ directory for test implementations and configurations.