diff --git a/jest.config.ts b/jest.config.ts index 9914401933..ed9a615897 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -25,7 +25,6 @@ const config: Config.InitialOptions = { errorOnDeprecated: true, // When in Continuous Integration, use only 1 worker (assuming "frugal" runner type) maxWorkers: env.CI === 'true' ? 1 : defaults.maxWorkers, - setupFilesAfterEnv: ['jest-expect-message'], testEnvironment: 'node', testMatch: ['**/?(*.)+(spec|test).ts'], testRunner: 'jest-circus/runner', diff --git a/package.json b/package.json index 026f5bbf0e..90690b0f36 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,6 @@ "eslint-plugin-prettier": "^4.0.0", "jest-circus": "^27.2.4", "jest-config": "^27.2.4", - "jest-expect-message": "^1.0.2", "lerna": "^4.0.0", "prettier": "^2.4.1", "standard-version": "^9.3.1", diff --git a/packages/@jsii/kernel/package.json b/packages/@jsii/kernel/package.json index 07f7eb6952..3a7c862a95 100644 --- a/packages/@jsii/kernel/package.json +++ b/packages/@jsii/kernel/package.json @@ -40,7 +40,6 @@ "@scope/jsii-calc-lib": "^0.0.0", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.2", - "@types/jest-expect-message": "^1.0.3", "@types/node": "^12.20.28", "@types/tar": "^4.0.5", "eslint": "^7.32.0", diff --git a/packages/@jsii/kernel/test/kernel.test.ts b/packages/@jsii/kernel/test/kernel.test.ts index 947ce2ffee..68eb991bac 100644 --- a/packages/@jsii/kernel/test/kernel.test.ts +++ b/packages/@jsii/kernel/test/kernel.test.ts @@ -579,10 +579,7 @@ defineTest( expect(obj2[api.TOKEN_REF]).toBeTruthy(); // verify that we received a ref as a result; const objid: string = obj2[api.TOKEN_REF]; - expect( - objid.startsWith('jsii-calc.JSObjectLiteralToNativeClass@'), - `${objid} does not have the intended prefix`, - ).toBeTruthy(); // verify the type of the returned object' + expect(objid).toMatch(/^jsii-calc.JSObjectLiteralToNativeClass@/); }, ); @@ -1524,12 +1521,13 @@ defineTest('ObjRefs are labeled with the "most correct" type', (sandbox) => { method: staticMethod, }).result as api.ObjRef; - expect( - deepEqualWithRegex(ret, typeSpec), - `Constructors.${staticMethod}() => ${JSON.stringify( - ret, - )}, does not match ${JSON.stringify(typeSpec)}`, - ).toBeTruthy(); + if (!deepEqualWithRegex(ret, typeSpec)) { + throw new Error( + `Constructors.${staticMethod}() => ${JSON.stringify( + ret, + )}, does not match ${JSON.stringify(typeSpec)}`, + ); + } } }); @@ -2207,7 +2205,7 @@ async function preparePackage(module: string, useCache = true) { } const packageRoot = findPackageRoot(module); - await new Promise((ok, ko) => { + await new Promise((ok, ko) => { const child = childProcess.spawn('npm', ['pack', packageRoot], { cwd: staging, shell: true, diff --git a/packages/jsii-config/package.json b/packages/jsii-config/package.json index daeffcae08..58f7d71ad7 100644 --- a/packages/jsii-config/package.json +++ b/packages/jsii-config/package.json @@ -21,7 +21,6 @@ "devDependencies": { "@types/inquirer": "^8.1.3", "@types/jest": "^27.0.2", - "@types/jest-expect-message": "^1.0.3", "@types/node": "^12.20.28", "@types/yargs": "^17.0.3", "eslint": "^7.32.0", diff --git a/packages/jsii-diff/package.json b/packages/jsii-diff/package.json index 724cf31a42..fe82688389 100644 --- a/packages/jsii-diff/package.json +++ b/packages/jsii-diff/package.json @@ -44,7 +44,6 @@ "devDependencies": { "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.2", - "@types/jest-expect-message": "^1.0.3", "@types/node": "^12.20.28", "@types/tar-fs": "^2.0.1", "eslint": "^7.32.0", diff --git a/packages/jsii-diff/test/util.ts b/packages/jsii-diff/test/util.ts index 4391a5e8ea..e9442683d1 100644 --- a/packages/jsii-diff/test/util.ts +++ b/packages/jsii-diff/test/util.ts @@ -26,10 +26,10 @@ export async function expectError( expect(mms.count).not.toBe(0); const msgs = Array.from(mms.messages()); - expect( - msgs.some((m) => error.test(m)), - `Expected error like ${error.toString()}, got ${msgs.join(', ')}`, - ).toBeTruthy(); + + if (!msgs.some((m) => error.test(m))) { + expect(msgs.join(',')).toMatch(error); + } } export async function compare( diff --git a/packages/jsii/package.json b/packages/jsii/package.json index c9033df37b..331f7210dd 100644 --- a/packages/jsii/package.json +++ b/packages/jsii/package.json @@ -54,7 +54,6 @@ "@types/deep-equal": "^1.0.1", "@types/fs-extra": "^9.0.13", "@types/jest": "^27.0.2", - "@types/jest-expect-message": "^1.0.3", "@types/node": "^12.20.28", "@types/semver": "^7.3.8", "clone": "^2.1.2",