-
Notifications
You must be signed in to change notification settings - Fork 646
chore: convert bdd tests to e2e tests #7539
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { ACM } from "@aws-sdk/client-acm"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-acm", () => { | ||
| let client: ACM; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new ACM({ region }); | ||
| }); | ||
|
|
||
| describe("Making a request to ACM service", () => { | ||
| it("should successfully list certificates", async () => { | ||
| const result = await client.listCertificates({}); | ||
|
|
||
| expect(result).toBeDefined(); | ||
| expect(result.CertificateSummaryList).toBeDefined(); | ||
| expect(Array.isArray(result.CertificateSummaryList)).toBe(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no need for a triple chain of assertions, since the third one covers all 3 |
||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle ValidationException for invalid certificate ARN", async () => { | ||
| await expect( | ||
| client.describeCertificate({ | ||
| CertificateArn: "fake_arn", | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "ValidationException", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { APIGateway } from "@aws-sdk/client-api-gateway"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-api-gateway", () => { | ||
| let client: APIGateway; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new APIGateway({ region }); | ||
| }); | ||
|
|
||
| describe("Making a request", () => { | ||
| it("should successfully get REST APIs", async () => { | ||
| const result = await client.getRestApis({}); | ||
|
|
||
| expect(result).toBeDefined(); | ||
| expect(result.items).toBeDefined(); | ||
| expect(Array.isArray(result.items)).toBe(true); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. only need one assertion |
||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle NotFoundException for invalid REST API ID", async () => { | ||
| await expect( | ||
| client.getRestApi({ | ||
| restApiId: "fake_id", | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "NotFoundException", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import { getE2eTestResources } from "@aws-sdk/aws-util-test/src"; | ||
| import { CloudFormation, paginateListStacks } from "@aws-sdk/client-cloudformation"; | ||
| import { beforeAll, describe, expect, test as it } from "vitest"; | ||
|
|
||
| describe("@aws-sdk/client-cloudformation", () => { | ||
| let client: CloudFormation; | ||
| let region: string; | ||
|
|
||
| beforeAll(async () => { | ||
| const e2eTestResourcesEnv = await getE2eTestResources(); | ||
| Object.assign(process.env, e2eTestResourcesEnv); | ||
|
|
||
| region = process?.env?.AWS_SMOKE_TEST_REGION as string; | ||
|
|
||
| client = new CloudFormation({ region }); | ||
| }); | ||
|
|
||
| describe("Describing stacks", () => { | ||
| it("should return stacks list when describing stacks is called", async () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DescribeStacks is the operation name, not describing stacks |
||
| const result = await client.describeStacks({}); | ||
|
|
||
| expect(result).toBeDefined(); | ||
| expect(result.Stacks).toBeDefined(); | ||
| expect(Array.isArray(result.Stacks)).toBe(true); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Error handling", () => { | ||
| it("should handle ValidationError for invalid stack creation", async () => { | ||
| const templateBody = '{"Resources":{"member":{"Type":"AWS::SQS::Queue"}}}'; | ||
|
|
||
| await expect( | ||
| client.createStack({ | ||
| TemplateBody: templateBody, | ||
| StackName: "", // Empty name should cause ValidationError | ||
| }) | ||
| ).rejects.toThrow( | ||
| expect.objectContaining({ | ||
| name: "ValidationError", | ||
| }) | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("Paginating responses", () => { | ||
| it("should paginate listStacks operation", async () => { | ||
| const paginator = paginateListStacks({ client }, {}); | ||
|
|
||
| let pageCount = 0; | ||
| let lastPage; | ||
|
|
||
| for await (const page of paginator) { | ||
| pageCount++; | ||
| lastPage = page; | ||
| if (pageCount >= 3) break; // Get at least three pages | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this test doesn't match the original test "the last page must not contain a marker" i'm guessing this refers to the pagination token
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes you are right. |
||
| } | ||
|
|
||
| expect(pageCount).toBeGreaterThanOrEqual(1); | ||
| expect(lastPage).toBeDefined(); | ||
| }); | ||
| }); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import { defineConfig } from "vitest/config"; | ||
|
|
||
| export default defineConfig({ | ||
| test: { | ||
| exclude: ["**/*.browser.e2e.spec.ts"], | ||
| include: ["**/*.e2e.spec.ts"], | ||
| environment: "node", | ||
| }, | ||
| mode: "development", | ||
| }); |
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
include a
test:e2e:watchscript counterpart for all test scripts