Skip to content
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

test: conversions to vitest #6585

Merged
merged 3 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
71 changes: 0 additions & 71 deletions clients/client-cognito-identity/karma.conf.js

This file was deleted.

3 changes: 2 additions & 1 deletion clients/client-cognito-identity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo cognito-identity",
"test:e2e": "ts-mocha test/**/*.ispec.ts && karma start karma.conf.js"
"test:e2e": "vitest run -c vitest.config.e2e.ts",
"test:e2e:watch": "vitest watch -c vitest.config.e2e.ts"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
/// <reference types="mocha" />
/**
* This is the integration test that make sure the client can make request cross-platform-ly
* in NodeJS, Chromium and Firefox. This test is written in mocha.
*/
import { expect } from "chai";
import { beforeAll, describe, expect, test as it } from "vitest";

import { getIntegTestResources } from "../../../../tests/e2e/get-integ-test-resources";
import { CognitoIdentity } from "../../src/index";
// There will be default values of defaultRegion, credentials, and isBrowser variable in browser tests.
// Define the values for Node.js tests
const region: string | undefined = (globalThis as any).defaultRegion || process?.env?.AWS_SMOKE_TEST_REGION;
const IdentityPoolId =
(globalThis as any)?.window?.__env__?.AWS_SMOKE_TEST_IDENTITY_POOL_ID ||
process?.env?.AWS_SMOKE_TEST_IDENTITY_POOL_ID;

describe("@aws-sdk/client-cognito-identity", function () {
const unAuthClient = new CognitoIdentity({
region,
describe("@aws-sdk/client-cognito-identity", () => {
let unAuthClient: CognitoIdentity;
let region: string;
let IdentityPoolId: string;

beforeAll(async () => {
const integTestResourcesEnv = await getIntegTestResources();
Object.assign(process.env, integTestResourcesEnv);

region = process?.env?.AWS_SMOKE_TEST_REGION as string;
IdentityPoolId =
(globalThis as any)?.window?.__env__?.AWS_SMOKE_TEST_IDENTITY_POOL_ID ||
process?.env?.AWS_SMOKE_TEST_IDENTITY_POOL_ID;

unAuthClient = new CognitoIdentity({
region,
});
});

it("should successfully fetch Id and get credentials", async () => {
Expand Down
2 changes: 1 addition & 1 deletion clients/client-cognito-identity/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"rootDir": "src",
"useUnknownInCatchVariables": false
},
"exclude": ["test/"]
"exclude": ["test/", "vitest.*.ts"]
}
2 changes: 1 addition & 1 deletion clients/client-cognito-identity/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"declarationDir": "dist-types",
"emitDeclarationOnly": true
},
"exclude": ["test/**/*", "dist-types/**/*"]
"exclude": ["test/**/*", "dist-types/**/*", "vitest.*.ts"]
}
8 changes: 8 additions & 0 deletions clients/client-cognito-identity/vitest.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["**/*.e2e.spec.ts"],
environment: "happy-dom",
},
});
4 changes: 0 additions & 4 deletions clients/client-kinesis/jest.config.e2e.js

This file was deleted.

3 changes: 2 additions & 1 deletion clients/client-kinesis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo kinesis",
"test:e2e": "jest --config jest.config.e2e.js"
"test:e2e": "vitest run -c vitest.config.e2e.ts",
"test:e2e:watch": "vitest watch -c vitest.config.e2e.ts"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
4 changes: 3 additions & 1 deletion clients/client-kinesis/test/Kinesis.e2e.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { test as it, describe, expect } from "vitest";

import { KinesisClient, ListStreamsCommand } from "../src/index";

describe("@aws-sdk/client-kinesis", () => {
const client = new KinesisClient({});
const ONE_SECOND = 1 * 1000;

// TODO: not working in CI
xit(
it.skip(
`${ListStreamsCommand.name} should succeed`,
async () => {
const { StreamNames } = await client.send(new ListStreamsCommand({}));
Expand Down
2 changes: 1 addition & 1 deletion clients/client-kinesis/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
"rootDir": "src",
"useUnknownInCatchVariables": false
},
"exclude": ["test/"]
"exclude": ["test/", "vitest.*.ts"]
}
2 changes: 1 addition & 1 deletion clients/client-kinesis/tsconfig.types.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"declarationDir": "dist-types",
"emitDeclarationOnly": true
},
"exclude": ["test/**/*", "dist-types/**/*"]
"exclude": ["test/**/*", "dist-types/**/*", "vitest.*.ts"]
}
8 changes: 8 additions & 0 deletions clients/client-kinesis/vitest.config.e2e.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
include: ["**/*.e2e.spec.ts"],
environment: "node",
},
});
1 change: 1 addition & 0 deletions clients/client-s3/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*.log
package-lock.json
!karma.conf.js
/test/browser-build/browser-s3-bundle.js
5 changes: 0 additions & 5 deletions clients/client-s3/jest.config.e2e.js

This file was deleted.

74 changes: 0 additions & 74 deletions clients/client-s3/karma.conf.js

This file was deleted.

11 changes: 6 additions & 5 deletions clients/client-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo",
"extract:docs": "api-extractor run --local",
"generate:client": "node ../../scripts/generate-clients/single-service --solo s3",
"test": "yarn test:unit",
"test:e2e": "yarn test:e2e:node && yarn test:e2e:browser",
"test:e2e:browser": "ts-mocha test/**/*.browser.ispec.ts && karma start karma.conf.js",
"test:e2e:node": "jest --c jest.config.e2e.js",
"test:unit": "ts-mocha test/unit/**/*.spec.ts"
"test": "vitest run",
"test:watch": "vitest watch",
"test:e2e": "vitest run -c vitest.config.e2e.ts && yarn test:browser",
"test:e2e:watch": "vitest watch -c vitest.config.e2e.ts",
"test:browser": "node ./test/browser-build/esbuild && vitest run -c vitest.config.browser.ts",
"test:browser:watch": "node ./test/browser-build/esbuild && vitest watch -c vitest.config.browser.ts"
},
"main": "./dist-cjs/index.js",
"types": "./dist-types/index.d.ts",
Expand Down
20 changes: 20 additions & 0 deletions clients/client-s3/test/browser-build/esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const esbuild = require("esbuild");
const path = require("path");

const buildOptions = {
platform: "browser",
target: ["chrome120"],
bundle: true,
format: "esm",
mainFields: ["module", "browser", "main"],
allowOverwrite: true,
entryPoints: [path.join(__dirname, "..", "..", "dist-es", "index.js")],
supported: {
"dynamic-import": false,
},
outfile: path.join(__dirname, "browser-s3-bundle.js"),
// packages: "external",
external: [],
};

esbuild.build(buildOptions);
Loading
Loading