Skip to content

Bug: Error: Environment variable AWS_REGION is required in Unit Tests in v2.25.0 #4334

@AplusKminus

Description

@AplusKminus

Expected Behavior

Simply upgrading 2.24.1 to 2.25.0 should not break existing behavior (unless specified in the release notes). Especially not unit tests that do not run in a Lambda context.

Current Behavior

All unit tests fail with the error message:

Error: Environment variable AWS_REGION is required

Code snippet

The file someFunction.ts:

import { Logger } from "@aws-lambda-powertools/logger";

const logger = new Logger({
    serviceName: "service-name",
});

export const someFunction = (input: string): string => {
    logger.info(input);
    return input;
};

The file someFunction.test.ts:

import { describe, expect, it } from "vitest";
import { someFunction } from "./someFunction.js";

describe("test someFunction", () => {
    it("should return its parameter", () => {
        expect(someFunction("test input")).toBe("test input");
    });
});

Steps to Reproduce

  1. Add the two files provided above and execute the test file.
  2. It should not fail.

Possible Solution

No response

Powertools for AWS Lambda (TypeScript) version

2.25.0

AWS Lambda function runtime

22.x

Packaging format used

npm

Execution logs

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingduplicateThis issue is a duplicate of an existing one

    Type

    No type

    Projects

    Status

    Closed

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions