Skip to content

Commit

Permalink
fix: flaxy unit tests (#495)
Browse files Browse the repository at this point in the history
Signed-off-by: hxtree <[email protected]>
  • Loading branch information
hxtree authored Nov 5, 2023
1 parent 375d29f commit ed59cbc
Show file tree
Hide file tree
Showing 23 changed files with 105 additions and 94 deletions.
4 changes: 2 additions & 2 deletions libraries/faker-factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions libraries/messaging-schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions libraries/nestjs-modules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions libraries/validation-schemas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./src/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./src/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions platform/api-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"artifact": "create-artifact @cats-cradle/api-gateway",
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.{ts,tsx}\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.{ts,tsx}\" --fix-dry-run",
"cdk:bootstrap": "cdk bootstrap",
Expand Down
4 changes: 2 additions & 2 deletions platform/cli-tools/create-artifact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"create-artifact": "bin/create-artifact",
"build": "tsc && tsc-alias",
"build:all": "rush build -t .",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"create-artifact": "bin/create-artifact",
"build": "tsc && tsc-alias",
"build:all": "rush build -t .",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run"
},
Expand Down
4 changes: 2 additions & 2 deletions platform/cli-tools/create-bundle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions platform/cli-tools/rush-coverage/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions platform/constructs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"depcheck": "npx depcheck"
Expand Down
4 changes: 2 additions & 2 deletions platform/lambda-layers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"build": "tsc",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/*.{js,ts}\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.{js,ts}\" --fix-dry-run",
"cdk:deploy": "cdk deploy",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`MainStack should match snapshot test 1`] = `
exports[`NestJsLambdaLayerStack should match snapshot test 1`] = `
{
"Outputs": {
"NestJSLayerVersionArn": {
"Value": {
"Ref": "NestJsAppLayerF9ACDB87",
Outputs: {
NestJSLayerVersionArn: {
Value: {
Ref: NestJsAppLayerF9ACDB87,
},
},
},
"Parameters": {
"BootstrapVersion": {
"Default": "/cdk-bootstrap/hnb659fds/version",
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]",
"Type": "AWS::SSM::Parameter::Value<String>",
Parameters: {
BootstrapVersion: {
Default: /cdk-bootstrap/hnb659fds/version,
Description: Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip],
Type: AWS::SSM::Parameter::Value<String>,
},
},
"Resources": {
"NestJsAppLayerF9ACDB87": {
"DeletionPolicy": "Delete",
"Properties": {
"CompatibleArchitectures": [
"x86_64",
"arm64",
Resources: {
NestJsAppLayerF9ACDB87: {
DeletionPolicy: Delete,
Properties: {
CompatibleArchitectures: [
x86_64,
arm64,
],
"Content": {
"S3Bucket": {
"Fn::Sub": "cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region}",
Content: {
S3Bucket: {
Fn::Sub: cdk-hnb659fds-assets-\${AWS::AccountId}-\${AWS::Region},
},
"S3Key": "2640a05f1ab7f3b50acbdb9b4601513df930c8841534d0432bf112cb1b9f61e5.zip",
S3Key: UNIQUE_HASH.zip,
},
"LayerName": {
"Fn::Join": [
"",
LayerName: {
Fn::Join: [
,
[
"arn:aws:lambda:",
arn:aws:lambda:,
{
"Ref": "AWS::Region",
Ref: AWS::Region,
},
":",
:,
{
"Ref": "AWS::AccountId",
Ref: AWS::AccountId,
},
":layer:NestJsAppLayer",
:layer:NestJsAppLayer,
],
],
},
},
"Type": "AWS::Lambda::LayerVersion",
"UpdateReplacePolicy": "Delete",
Type: AWS::Lambda::LayerVersion,
UpdateReplacePolicy: Delete,
},
"lambdalayernestjslatestversionB188CF78": {
"Properties": {
"Description": "NestJS Lambda Layer Latest Version",
"Name": "lambda-layer-nestjs-latest-version",
"Type": "String",
"Value": {
"Ref": "NestJsAppLayerF9ACDB87",
lambdalayernestjslatestversionB188CF78: {
Properties: {
Description: NestJS Lambda Layer Latest Version,
Name: lambda-layer-nestjs-latest-version,
Type: String,
Value: {
Ref: NestJsAppLayerF9ACDB87,
},
},
"Type": "AWS::SSM::Parameter",
Type: AWS::SSM::Parameter,
},
},
"Rules": {
"CheckBootstrapVersion": {
"Assertions": [
Rules: {
CheckBootstrapVersion: {
Assertions: [
{
"Assert": {
"Fn::Not": [
Assert: {
Fn::Not: [
{
"Fn::Contains": [
Fn::Contains: [
[
"1",
"2",
"3",
"4",
"5",
1,
2,
3,
4,
5,
],
{
"Ref": "BootstrapVersion",
Ref: BootstrapVersion,
},
],
},
],
},
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.",
AssertDescription: CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI.,
},
],
},
Expand Down
14 changes: 12 additions & 2 deletions platform/lambda-layers/stacks/nestjs-lambda-layer.stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,21 @@ import * as cdk from 'aws-cdk-lib';
import { Template } from 'aws-cdk-lib/assertions';
import { NestJsLambdaLayerStack } from './nestjs-lambda-layer.stack';

describe('MainStack', () => {
describe('NestJsLambdaLayerStack', () => {
it('should match snapshot test', () => {
const app = new cdk.App();
const stack = new NestJsLambdaLayerStack(app, 'MyTestStack');
const template = Template.fromStack(stack);
expect(template).toMatchSnapshot();

// TODO consider reworking to use DNS instead of incrementing and deploying each time
const customSnapshotSerializer = {
test: (val: any) => typeof val === 'string',
print: (val: any) => val
.replace(/deployment\d{8}T\d{9}Z[^:]+/, 'deployment_UNIQUE_HASH')
.replace(/[a-fA-F0-9]+\.zip/, 'UNIQUE_HASH.zip'),
};
expect.addSnapshotSerializer(customSnapshotSerializer);

expect(template.toJSON()).toMatchSnapshot();
});
});
4 changes: 2 additions & 2 deletions platform/pipeline/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"cdk": "cdk",
"hotswap": "cdk deploy --hotswap",
"lint": "",
Expand Down
4 changes: 2 additions & 2 deletions services/admin-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
"start": "next start",
"lint": "next lint --fix",
"lint:ci": "next lint",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage"
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand"
},
"dependencies": {
"@types/node": "20.8.2",
Expand Down
4 changes: 2 additions & 2 deletions services/authentication-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:all": "rush build -t .",
"artifact": "create-artifact @cats-cradle/authentication-service",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
4 changes: 2 additions & 2 deletions services/character-sheet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:all": "rush build -t .",
"artifact": "create-artifact @cats-cradle/character-sheet",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe('/character-sheets', () => {
const response = await supertest(app.getHttpServer())
.get(`/character-sheets/${v4()}`)
.expect(404);

expect(response.body).toMatchObject({
message: 'Not Found',
statusCode: 404,
Expand Down
4 changes: 2 additions & 2 deletions services/email-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:all": "rush build -t .",
"artifact": "create-artifact @cats-cradle/email-service",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
4 changes: 2 additions & 2 deletions services/html-to-pdf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./src/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./src/**/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
4 changes: 2 additions & 2 deletions services/jukebox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"build:all": "rush build -t .",
"artifact": "create-artifact @cats-cradle/jukebox",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
4 changes: 2 additions & 2 deletions services/luck-by-dice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./src/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./src/**/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down
4 changes: 2 additions & 2 deletions services/weather-control/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
"build": "tsc",
"build:all": "rush build -t .",
"watch": "tsc -w",
"test": "jest --logHeapUsage",
"test:cov": "jest --coverage",
"test": "jest --runInBand",
"test:cov": "jest --coverage --runInBand",
"lint": "eslint --format visualstudio \"./{stacks,src}/**/*.ts\" --fix",
"lint:ci": "eslint --format visualstudio \"./{stacks,src}/*.ts\" --fix-dry-run",
"docs": "typedoc --entryPointStrategy expand ./src",
Expand Down

0 comments on commit ed59cbc

Please sign in to comment.