Skip to content

Commit

Permalink
test(parameters): migrate tests to vitest (#3304)
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamorosi authored Nov 11, 2024
1 parent 003c654 commit 02b658a
Show file tree
Hide file tree
Showing 27 changed files with 646 additions and 860 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ jobs:
"packages/logger",
"packages/tracer",
"packages/parser",
"packages/parameters",
]
fail-fast: false
steps:
Expand Down Expand Up @@ -91,12 +92,10 @@ jobs:
nodeVersion: ${{ matrix.version }}
- name: Run linting
run: |
npm run lint -w packages/metrics \
-w packages/parameters
npm run lint -w packages/metrics
- name: Run unit tests
run: |
npm t -w packages/metrics \
-w packages/parameters
npm t -w packages/metrics
check-examples:
runs-on: ubuntu-latest
env:
Expand Down
3 changes: 1 addition & 2 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
npm t \
-w packages/metrics \
-w packages/parameters
-w packages/metrics

npx vitest --run \
--exclude tests/unit/layer-publisher.test.ts \
Expand Down
35 changes: 0 additions & 35 deletions packages/parameters/jest.config.cjs

This file was deleted.

15 changes: 8 additions & 7 deletions packages/parameters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@
"access": "public"
},
"scripts": {
"test": "npm run test:unit",
"test:unit": "jest --group=unit --detectOpenHandles --coverage --verbose",
"jest": "jest --detectOpenHandles --verbose",
"test:e2e:nodejs18x": "RUNTIME=nodejs18x jest --group=e2e",
"test:e2e:nodejs20x": "RUNTIME=nodejs20x jest --group=e2e",
"test:e2e": "jest --group=e2e",
"watch": "jest --watch",
"test": "vitest --run tests/unit",
"test:unit": "vitest --run tests/unit",
"test:unit:coverage": "vitest --run tests/unit --coverage.enabled --coverage.thresholds.100 --coverage.include='src/**'",
"test:unit:types": "vitest --run tests/types --typecheck",
"test:unit:watch": "vitest tests/unit",
"test:e2e:nodejs18x": "RUNTIME=nodejs18x vitest --run tests/e2e",
"test:e2e:nodejs20x": "RUNTIME=nodejs20x vitest --run tests/e2e",
"test:e2e": "vitest --run tests/e2e",
"build:cjs": "tsc --build tsconfig.json && echo '{ \"type\": \"commonjs\" }' > lib/cjs/package.json",
"build:esm": "tsc --build tsconfig.esm.json && echo '{ \"type\": \"module\" }' > lib/esm/package.json",
"build": "npm run build:esm & npm run build:cjs",
Expand Down
7 changes: 5 additions & 2 deletions packages/parameters/src/appconfig/AppConfigProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,12 @@ class AppConfigProvider extends BaseProvider {
/**
* Retrieving multiple configurations is not supported by AWS AppConfig.
*/
public async getMultiple(path: string, _options?: unknown): Promise<void> {
/* v8 ignore start */ public async getMultiple(
path: string,
_options?: unknown
): Promise<void> {
await super.getMultiple(path);
}
} /* v8 ignore stop */

/**
* Retrieve a configuration from AWS AppConfig.
Expand Down
7 changes: 5 additions & 2 deletions packages/parameters/src/secrets/SecretsProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,12 @@ class SecretsProvider extends BaseProvider {
/**
* Retrieving multiple parameter values is not supported with AWS Secrets Manager.
*/
public async getMultiple(path: string, _options?: unknown): Promise<void> {
/* v8 ignore start */ public async getMultiple(
path: string,
_options?: unknown
): Promise<void> {
await super.getMultiple(path);
}
} /* v8 ignore stop */

/**
* Retrieve a configuration from AWS Secrets Manager.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Test AppConfigProvider class
*
* @group e2e/parameters/appconfig/class
*/
import { join } from 'node:path';
import {
TestInvocationLogs,
Expand All @@ -11,6 +6,7 @@ import {
} from '@aws-lambda-powertools/testing-utils';
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
import { toBase64 } from '@smithy/util-base64';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { TestAppConfigWithProfiles } from '../helpers/resources.js';
import {
RESOURCE_NAME_PREFIX,
Expand Down
6 changes: 1 addition & 5 deletions packages/parameters/tests/e2e/dynamoDBProvider.class.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Test DynamoDBProvider class
*
* @group e2e/parameters/dynamodb/class
*/
import { join } from 'node:path';
import {
TestInvocationLogs,
Expand All @@ -11,6 +6,7 @@ import {
} from '@aws-lambda-powertools/testing-utils';
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
import { AttributeType } from 'aws-cdk-lib/aws-dynamodb';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { TestDynamodbTableWithItems } from '../helpers/resources.js';
import {
RESOURCE_NAME_PREFIX,
Expand Down
6 changes: 1 addition & 5 deletions packages/parameters/tests/e2e/secretsProvider.class.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/**
* Test SecretsPorovider class
*
* @group e2e/parameters/secrets/class
*/
import { join } from 'node:path';
import {
TestInvocationLogs,
Expand All @@ -11,6 +6,7 @@ import {
} from '@aws-lambda-powertools/testing-utils';
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
import { SecretValue } from 'aws-cdk-lib';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { TestSecret } from '../helpers/resources.js';
import {
RESOURCE_NAME_PREFIX,
Expand Down
6 changes: 1 addition & 5 deletions packages/parameters/tests/e2e/ssmProvider.class.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
/**
* Test SSMProvider class
*
* @group e2e/parameters/ssm/class
*/
import { join } from 'node:path';
import {
TestInvocationLogs,
TestStack,
invokeFunctionOnce,
} from '@aws-lambda-powertools/testing-utils';
import { TestNodejsFunction } from '@aws-lambda-powertools/testing-utils/resources/lambda';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import {
TestSecureStringParameter,
TestStringParameter,
Expand Down
11 changes: 0 additions & 11 deletions packages/parameters/tests/helpers/populateEnvironmentVariables.ts

This file was deleted.

10 changes: 7 additions & 3 deletions packages/parameters/tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"rootDir": "../",
"rootDir": "../../",
"noEmit": true
},
"include": ["../src/**/*", "./**/*"]
}
"include": [
"../../testing/src/setupEnv.ts",
"../src/**/*",
"./**/*",
]
}
Loading

0 comments on commit 02b658a

Please sign in to comment.