From ddc8101cea1b32b7cfa19d12c80fcff6e08ec88f Mon Sep 17 00:00:00 2001 From: Abe K <219340+abdala@users.noreply.github.com> Date: Mon, 1 Jun 2026 13:11:29 +0200 Subject: [PATCH 1/2] Remove extra assert library --- assert/README.md | 3 - assert/package.json | 26 ------ assert/src/index.ts | 52 ------------ assert/test/index.test.ts | 85 ------------------- assert/tsconfig.json | 6 -- dtc-aws-plugin/package.json | 1 - dtc-aws-plugin/src/dynamo-db-plugin.ts | 7 +- dtc-aws-plugin/src/lambda-plugin.ts | 4 +- dtc-aws-plugin/src/rds-data-plugin.ts | 4 +- dtc-graphql-plugin/package.json | 1 - dtc-graphql-plugin/src/graphql-call-plugin.ts | 5 +- dtc-graphql-plugin/test/nock-appsync.ts | 3 +- dtc-mysql-plugin/package.json | 1 - dtc-mysql-plugin/src/mysql-mock-plugin.ts | 3 +- dtc-playwright-plugin/package.json | 1 - dtc-redis-plugin/package.json | 1 - dtc/package.json | 1 - dtc/src/plugins/function-call-plugin.ts | 5 +- dtc/src/plugins/http-call-plugin.ts | 3 +- dtc/src/plugins/http-mock-plugin.ts | 3 +- nock-aws/src/helpers.ts | 3 +- package.json | 3 +- 22 files changed, 17 insertions(+), 204 deletions(-) delete mode 100644 assert/README.md delete mode 100644 assert/package.json delete mode 100644 assert/src/index.ts delete mode 100644 assert/test/index.test.ts delete mode 100644 assert/tsconfig.json diff --git a/assert/README.md b/assert/README.md deleted file mode 100644 index d5e5965..0000000 --- a/assert/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Extra Assert - -Provide extra assertions to use together with node test runner diff --git a/assert/package.json b/assert/package.json deleted file mode 100644 index 31097bf..0000000 --- a/assert/package.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "name": "@cgauge/assert", - "version": "0.27.0", - "description": "Extra assert library", - "type": "module", - "repository": { - "type": "git", - "url": "git+https://github.com/cgauge/packages.git" - }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "dependencies": { - "@cgauge/log": "^0.27.0" - }, - "author": "Abdala Cerqueira", - "license": "LGPL-3.0-or-later", - "scripts": { - "build": "tsc --build --verbose", - "test": "tsx --test test/*.test.ts", - "test:only": "tsx --test --test-only test/*.test.ts", - "test:coverage": "tsx --experimental-test-coverage --test test/*.test.ts" - } -} diff --git a/assert/src/index.ts b/assert/src/index.ts deleted file mode 100644 index 0a6656f..0000000 --- a/assert/src/index.ts +++ /dev/null @@ -1,52 +0,0 @@ -import nodeAssert from 'node:assert' -import createLogger from '@cgauge/log' - -const logger = createLogger('assert'); - -interface ExtraAssertions { - objectContains>( - actual: Record, - expected: T, - message?: string | Error, - ): asserts actual is Partial -} - -const isObject = (v: unknown) => typeof v === 'object' && v !== null - -const assertions: ExtraAssertions = { - objectContains>( - actual: Record, - expected: T, - message?: string | Error, - ): asserts actual is Partial { - logger.debug('objectContains:', actual, expected) - - if (typeof actual !== 'object' || typeof expected !== 'object') { - nodeAssert.deepEqual(actual, expected, `${message ?? ''}Both actual and expected values must be objects`) - } - - if (Array.isArray(actual) && Array.isArray(expected) && actual.length !== expected.length) { - nodeAssert.deepEqual( - actual, - expected, - `${message ?? ''}Both actual and expected should have the same number of elements`, - ) - } - - const expectedKeys = Object.keys(expected) - - for (const key of expectedKeys) { - if (!(key in actual)) { - nodeAssert.deepEqual(actual, expected, `${message ?? ''}Invalid key [${key.toString()}]`) - } - - if (isObject(expected[key]) && isObject(actual[key])) { - assertions.objectContains(actual[key], expected[key], message) - } else if (actual[key] !== expected[key]) { - nodeAssert.deepEqual(actual, expected, `${message ?? ''}Invalid key [${key.toString()}]`) - } - } - }, -} - -export default assertions diff --git a/assert/test/index.test.ts b/assert/test/index.test.ts deleted file mode 100644 index 4be0a7a..0000000 --- a/assert/test/index.test.ts +++ /dev/null @@ -1,85 +0,0 @@ -import {test} from 'node:test' -import extraAssert from '../src/index.js' -import nodeAssert from 'node:assert' - -test('It partially check object properties', () => { - const actual = {a: 'b', c: 'd'} - const expected = {c: 'd'} - - extraAssert.objectContains(actual, expected) -}) - -test('It fails when object properties does not match', () => { - const actual = {a: 'b', c: 'd'} - const expected = {c: 'e'} - - nodeAssert.throws( - () => { - extraAssert.objectContains(actual, expected) - }, - { - name: 'AssertionError', - message: 'Invalid key [c]', - }, - ) -}) - -test('It fails when array does not have the same size', () => { - const actual = [{a: 'b'}, {c: 'd'}] - const expected = [{c: 'e'}] - - nodeAssert.throws( - () => { - extraAssert.objectContains(actual, expected) - }, - { - name: 'AssertionError', - message: 'Both actual and expected should have the same number of elements', - }, - ) -}) - -test('It fails when key is null', () => { - const actual = {a: null} - const expected = {a: {c: 'b'}} - - nodeAssert.throws( - () => { - extraAssert.objectContains(actual, expected) - }, - { - name: 'AssertionError', - message: 'Invalid key [a]', - }, - ) -}) - -test('It fails when values is not an object', () => { - const actual = 1 as any - const expected = {a: 1} - - nodeAssert.throws( - () => { - extraAssert.objectContains(actual, expected) - }, - { - name: 'AssertionError', - message: 'Both actual and expected values must be objects', - }, - ) -}) - -test('It fails if expected key is not present', () => { - const actual = {b: 2} - const expected = {a: 1} - - nodeAssert.throws( - () => { - extraAssert.objectContains(actual, expected) - }, - { - name: 'AssertionError', - message: 'Invalid key [a]', - }, - ) -}) diff --git a/assert/tsconfig.json b/assert/tsconfig.json deleted file mode 100644 index 79baa5f..0000000 --- a/assert/tsconfig.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "extends": "../tsconfig.json", - "compilerOptions": { - "outDir": "./dist", - }, -} diff --git a/dtc-aws-plugin/package.json b/dtc-aws-plugin/package.json index ab69d4b..3a110b0 100644 --- a/dtc-aws-plugin/package.json +++ b/dtc-aws-plugin/package.json @@ -22,7 +22,6 @@ "@aws-sdk/client-sns": "^3.645.0", "@aws-sdk/lib-dynamodb": "^3.645.0", "@aws-sdk/util-dynamodb": "^3.645.0", - "@cgauge/assert": "^0.27.0", "@cgauge/dtc": "^0.27.0", "@cgauge/log": "^0.27.0", "@cgauge/nock-aws": "^0.27.0", diff --git a/dtc-aws-plugin/src/dynamo-db-plugin.ts b/dtc-aws-plugin/src/dynamo-db-plugin.ts index 9f91257..822840a 100644 --- a/dtc-aws-plugin/src/dynamo-db-plugin.ts +++ b/dtc-aws-plugin/src/dynamo-db-plugin.ts @@ -1,7 +1,6 @@ import {DynamoDB, AttributeValue} from '@aws-sdk/client-dynamodb' import {DynamoDBDocument} from '@aws-sdk/lib-dynamodb' -import extraAssert from '@cgauge/assert' -import nodeAssert from 'node:assert' +import nodeAssert from 'node:assert/strict' import {is, optional, unknown, record, diff, TypeFromSchema, union} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -73,7 +72,7 @@ export const assertExists = async (statement: DynamoAssert): Promise => { nodeAssert.fail('(DynamoDB) Item not found') } - extraAssert.objectContains(result.Item, statement.item) + nodeAssert.partialDeepStrictEqual(result.Item, statement.item) } if ('query' in statement) { @@ -97,7 +96,7 @@ export const assertExists = async (statement: DynamoAssert): Promise => { for (const item of result.Items) { try { - extraAssert.objectContains(item, statement.item) + nodeAssert.partialDeepStrictEqual(item, statement.item) matched = true } catch (error) {} } diff --git a/dtc-aws-plugin/src/lambda-plugin.ts b/dtc-aws-plugin/src/lambda-plugin.ts index 3720488..d75a997 100644 --- a/dtc-aws-plugin/src/lambda-plugin.ts +++ b/dtc-aws-plugin/src/lambda-plugin.ts @@ -1,5 +1,5 @@ import {Lambda} from '@aws-sdk/client-lambda' -import extraAssert from '@cgauge/assert' +import nodeAssert from 'node:assert/strict' import {is, unknown, record, diff} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -64,7 +64,7 @@ export const assert = async (args: unknown) => { throw new Error(`(Lambda) Invalid argument on assert: ${mismatch[0]}`) } - extraAssert.objectContains(args.lambda, response) + nodeAssert.partialDeepStrictEqual(response, args.lambda) return true } diff --git a/dtc-aws-plugin/src/rds-data-plugin.ts b/dtc-aws-plugin/src/rds-data-plugin.ts index c3f2ba1..757d3b6 100644 --- a/dtc-aws-plugin/src/rds-data-plugin.ts +++ b/dtc-aws-plugin/src/rds-data-plugin.ts @@ -1,5 +1,5 @@ import {RDSData, SqlParameter} from '@aws-sdk/client-rds-data' -import extraAssert from '@cgauge/assert' +import nodeAssert from 'node:assert/strict' import {is, unknown, diff, optional, TypeFromSchema, record, intersection} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -75,7 +75,7 @@ export const assert = async (args: unknown): Promise => { args.rds.map(async (v) => { const response = await executeStatement(v as RDSDataCallSql) - extraAssert.objectContains(v.response, response) + nodeAssert.partialDeepStrictEqual(response, v.response) }), ) diff --git a/dtc-graphql-plugin/package.json b/dtc-graphql-plugin/package.json index 337d621..80ff48c 100644 --- a/dtc-graphql-plugin/package.json +++ b/dtc-graphql-plugin/package.json @@ -15,7 +15,6 @@ "author": "Salam Suleymanov", "license": "LGPL-3.0-or-later", "dependencies": { - "@cgauge/assert": "^0.27.0", "@cgauge/dtc": "^0.27.0", "@cgauge/type-guard": "^0.27.0", "@cgauge/log": "^0.27.0", diff --git a/dtc-graphql-plugin/src/graphql-call-plugin.ts b/dtc-graphql-plugin/src/graphql-call-plugin.ts index 165ddf4..df41131 100644 --- a/dtc-graphql-plugin/src/graphql-call-plugin.ts +++ b/dtc-graphql-plugin/src/graphql-call-plugin.ts @@ -1,6 +1,5 @@ -import extraAssert from '@cgauge/assert' import {GraphQLClient} from 'graphql-request' -import nodeAssert from 'node:assert' +import nodeAssert from 'node:assert/strict' import {is, record, diff, optional, unknown, intersection} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -61,7 +60,7 @@ export const assert = async (args: unknown): Promise => { } } - extraAssert.objectContains(response, args.graphql) + nodeAssert.partialDeepStrictEqual(response, args.graphql) return true } diff --git a/dtc-graphql-plugin/test/nock-appsync.ts b/dtc-graphql-plugin/test/nock-appsync.ts index 664f901..89fd2aa 100644 --- a/dtc-graphql-plugin/test/nock-appsync.ts +++ b/dtc-graphql-plugin/test/nock-appsync.ts @@ -1,7 +1,6 @@ import nock from 'nock' import {RequestDocument} from 'graphql-request' import nodeAssert from 'node:assert/strict' -import extraAssert from '@cgauge/assert' nock.disableNetConnect() @@ -16,7 +15,7 @@ export const partialBodyCheck = (expected: AppSyncRequest) => (body: Record { if (variables) { nodeAssert.deepEqual(calls[i].arguments[0], sql) - extraAssert.objectContains(calls[i].arguments[1], variables) + nodeAssert.partialDeepStrictEqual(calls[i].arguments[1], variables) } else { nodeAssert.deepEqual(calls[i].arguments, [sql]) } diff --git a/dtc-playwright-plugin/package.json b/dtc-playwright-plugin/package.json index 6a97efb..247cb51 100644 --- a/dtc-playwright-plugin/package.json +++ b/dtc-playwright-plugin/package.json @@ -15,7 +15,6 @@ "author": "Abdala Cerqueira", "license": "LGPL-3.0-or-later", "dependencies": { - "@cgauge/assert": "^0.27.0", "@cgauge/dtc": "^0.27.0", "@cgauge/log": "^0.27.0", "@cgauge/type-guard": "^0.27.0", diff --git a/dtc-redis-plugin/package.json b/dtc-redis-plugin/package.json index 53e5c71..351f932 100644 --- a/dtc-redis-plugin/package.json +++ b/dtc-redis-plugin/package.json @@ -15,7 +15,6 @@ "author": "Salam Suleymanov", "license": "LGPL-3.0-or-later", "dependencies": { - "@cgauge/assert": "^0.27.0", "@cgauge/dtc": "^0.27.0", "@cgauge/type-guard": "^0.27.0" }, diff --git a/dtc/package.json b/dtc/package.json index fd8b90d..32568ff 100644 --- a/dtc/package.json +++ b/dtc/package.json @@ -18,7 +18,6 @@ "author": "Abdala Cerqueira", "license": "LGPL-3.0-or-later", "dependencies": { - "@cgauge/assert": "^0.27.0", "@cgauge/log": "^0.27.0", "@cgauge/type-guard": "^0.27.0", "cleye": "^1.3.2", diff --git a/dtc/src/plugins/function-call-plugin.ts b/dtc/src/plugins/function-call-plugin.ts index 015df15..fb21b57 100644 --- a/dtc/src/plugins/function-call-plugin.ts +++ b/dtc/src/plugins/function-call-plugin.ts @@ -1,5 +1,4 @@ -import extraAssert from '@cgauge/assert' -import nodeAssert from 'node:assert' +import nodeAssert from 'node:assert/strict' import {is, optional, unknown, record, diff, intersection, union} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -67,7 +66,7 @@ export const assert = async (args: unknown): Promise => { } if (response && typeof args.function === 'object' && args.function !== null) { - extraAssert.objectContains(response, args.function) + nodeAssert.partialDeepStrictEqual(response, args.function) } return true diff --git a/dtc/src/plugins/http-call-plugin.ts b/dtc/src/plugins/http-call-plugin.ts index caf43b8..62bab05 100644 --- a/dtc/src/plugins/http-call-plugin.ts +++ b/dtc/src/plugins/http-call-plugin.ts @@ -1,5 +1,4 @@ import nodeAssert from 'node:assert/strict' -import extraAssert from '@cgauge/assert' import {is, union, optional, unknown, record, assert as typeAssert, diff} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -59,7 +58,7 @@ export const assert = async (args: unknown): Promise => { nodeAssert.deepStrictEqual(textResponse, args.http) } else { typeAssert(jsonResponse, record(String, unknown)) - extraAssert.objectContains(jsonResponse, args.http) + nodeAssert.partialDeepStrictEqual(jsonResponse, args.http) } return true diff --git a/dtc/src/plugins/http-mock-plugin.ts b/dtc/src/plugins/http-mock-plugin.ts index 121e58e..c53b6f3 100644 --- a/dtc/src/plugins/http-mock-plugin.ts +++ b/dtc/src/plugins/http-mock-plugin.ts @@ -1,5 +1,4 @@ import nodeAssert from 'node:assert/strict' -import extraAssert from '@cgauge/assert' import nock from 'nock' import {diff, is, optional, record, union, unknown} from '@cgauge/type-guard' import createLogger from '@cgauge/log' @@ -25,7 +24,7 @@ export const partialBodyCheck = (expected: string | Record) => return true } - extraAssert.objectContains(body, expected) + nodeAssert.partialDeepStrictEqual(body, expected) return true } diff --git a/nock-aws/src/helpers.ts b/nock-aws/src/helpers.ts index 316f410..e680c89 100644 --- a/nock-aws/src/helpers.ts +++ b/nock-aws/src/helpers.ts @@ -1,5 +1,4 @@ import nodeAssert from 'node:assert/strict' -import extraAssert from '@cgauge/assert' import nock from 'nock' const debug = (...message: any) => { process.env.NOCK_AWS_DEBUG && console.log(...message) } @@ -21,7 +20,7 @@ export const partialBodyCheck = (expected: string | Record) => return true } - extraAssert.objectContains(body, expected) + nodeAssert.partialDeepStrictEqual(body, expected) return true } diff --git a/package.json b/package.json index c415dba..b93ec24 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,6 @@ "author": "Abdala Cerqueira", "license": "LGPL-3.0-or-later", "workspaces": [ - "assert", "dtc", "dtc-aws-plugin", "dtc-graphql-plugin", @@ -19,7 +18,7 @@ ], "scripts": { "clean": "find . -name 'dist' -type d -prune -not -path './node_modules/*' -exec rm -rf '{}' +", - "dependencies": "echo log assert type-guard dtc | xargs -n1 npm run build --if-present --workspace", + "dependencies": "echo log type-guard dtc | xargs -n1 npm run build --if-present --workspace", "build": "npm run dependencies && npm query .workspace | node -p 'JSON.parse(fs.readFileSync(0)).map(ws => ws.name).join(\"\\n\")' | xargs -I {} -P 0 npm run build --if-present --workspace '{}'", "test": "npm query .workspace | node -p 'JSON.parse(fs.readFileSync(0)).map(ws => ws.name).join(\"\\n\")' | xargs -I {} -P 0 npm run test --if-present --workspace '{}'" }, From 5c9fed7b9408b7e6d142198e3e0ad18790a93369 Mon Sep 17 00:00:00 2001 From: Abe K <219340+abdala@users.noreply.github.com> Date: Thu, 11 Jun 2026 13:10:43 +0200 Subject: [PATCH 2/2] Upgrade node types --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index b93ec24..0c7b7b4 100644 --- a/package.json +++ b/package.json @@ -23,7 +23,7 @@ "test": "npm query .workspace | node -p 'JSON.parse(fs.readFileSync(0)).map(ws => ws.name).join(\"\\n\")' | xargs -I {} -P 0 npm run test --if-present --workspace '{}'" }, "devDependencies": { - "@types/node": "^20.0.0", + "@types/node": "^24.0.0", "tsx": "^4.0.0", "typescript": "^5.0.0" }