|
| 1 | +// Reserved variables |
| 2 | +process.env._X_AMZN_TRACE_ID = |
| 3 | + 'Root=1-5759e988-bd862e3fe1be46a994272793;Parent=557abcec3ee5a047;Sampled=1'; |
| 4 | +process.env.AWS_LAMBDA_FUNCTION_NAME = 'my-lambda-function'; |
| 5 | +process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE = '128'; |
| 6 | +process.env.AWS_LAMBDA_FUNCTION_VERSION = '$LATEST'; |
| 7 | +if ( |
| 8 | + process.env.AWS_REGION === undefined && |
| 9 | + process.env.CDK_DEFAULT_REGION === undefined |
| 10 | +) { |
| 11 | + process.env.AWS_REGION = 'eu-west-1'; |
| 12 | +} |
| 13 | + |
| 14 | +// Powertools for AWS Lambda (TypeScript) variables |
| 15 | +process.env.POWERTOOLS_LOG_LEVEL = 'DEBUG'; |
| 16 | +process.env.POWERTOOLS_SERVICE_NAME = 'hello-world'; |
| 17 | + |
| 18 | +jest.spyOn(console, 'error').mockImplementation(); |
| 19 | +jest.spyOn(console, 'warn').mockImplementation(); |
| 20 | +jest.spyOn(console, 'info').mockImplementation(); |
| 21 | +jest.spyOn(console, 'debug').mockImplementation(); |
| 22 | +jest.spyOn(console, 'log').mockImplementation(); |
| 23 | + |
| 24 | +jest.mock('node:console', () => ({ |
| 25 | + ...jest.requireActual('node:console'), |
| 26 | + Console: jest.fn().mockImplementation(() => ({ |
| 27 | + log: jest.fn(), |
| 28 | + debug: jest.fn(), |
| 29 | + info: jest.fn(), |
| 30 | + warn: jest.fn(), |
| 31 | + error: jest.fn(), |
| 32 | + })), |
| 33 | +})); |
| 34 | + |
| 35 | +declare global { |
| 36 | + namespace NodeJS { |
| 37 | + interface ProcessEnv { |
| 38 | + _X_AMZN_TRACE_ID: string | undefined; |
| 39 | + AWS_LAMBDA_FUNCTION_NAME: string | undefined; |
| 40 | + AWS_LAMBDA_FUNCTION_MEMORY_SIZE: string | undefined; |
| 41 | + AWS_LAMBDA_FUNCTION_VERSION: string | undefined; |
| 42 | + AWS_REGION: string | undefined; |
| 43 | + CDK_DEFAULT_REGION: string | undefined; |
| 44 | + POWERTOOLS_LOG_LEVEL: string | undefined; |
| 45 | + POWERTOOLS_SERVICE_NAME: string | undefined; |
| 46 | + POWERTOOLS_DEV: string | undefined; |
| 47 | + POWERTOOLS_LOGGER_LOG_EVENT: string | undefined; |
| 48 | + } |
| 49 | + } |
| 50 | +} |
| 51 | + |
| 52 | +export type {}; |
0 commit comments