TESTING.md
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-core
You can run specific test suites using scripts from packages/sf-core/package.json. For example:
npm run test:resolvers -w @serverlessinc/sf-core
The 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-valueresolvers/sample-secret:{
"num": 1,
"str": "secret",
"arr": [true, false]
}
serverless-compose-state-bucket-integration-test
terraform-s3-resolver-test-bucket
resolvers-integration-test
test.txtfile contentterraform-s3-resolver-test-lock-table
LockID (String)sfc-nodejs-resolvers-integration-test
ServerlessDeploymentBucketName: sfc-nodejs-resolvers-inte-serverlessdeploymentbuck-6vskiu5gzt1uFunction1LambdaFunctionQualifiedArn: arn:aws:lambda:us-east-1:762003938904:function:sfc-nodejs-resolvers-integration-test-function1:1sfc-nodejs-resolvers-integration-test
ServerlessDeploymentBucketName: sfc-nodejs-resolvers-inte-serverlessdeploymentbuck-vky0nzemsvvrFunction1LambdaFunctionQualifiedArn: arn:aws:lambda:eu-west-1:762003938904:function:sfc-nodejs-resolvers-integration-test-function1:1resolvers-custom-test:dashboard-param: dashboard-valueresolver-output-producer:outputs:
str: string-value
num: 42
obj:
foo: bar
serverlesstestaccount organizationserverless-test-01 workspaceFor any issues, refer to the tests/integration/ directory for test implementations and configurations.