Skip to content

Commit

Permalink
chore: remove jest-expect-message (#3039)
Browse files Browse the repository at this point in the history
The combination of:

* jest 27
* ts-jest
* jest-expect-message

Leads to any test that wants to report an error message failing with
the error:

```
TypeError: matcherResult.message is not a function
```

(ref: mattphillips/jest-expect-message#39)

The result is that the actual error is swallowed, and this is very
unhelpful.

Since we only used to use `jest-expect-message` in one place anyway,
remove it.



---

By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license].

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
  • Loading branch information
rix0rrr committed Oct 7, 2021
1 parent b329670 commit 3972932
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 21 deletions.
1 change: 0 additions & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/@jsii/kernel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
20 changes: 9 additions & 11 deletions packages/@jsii/kernel/test/kernel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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@/);
},
);

Expand Down Expand Up @@ -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)}`,
);
}
}
});

Expand Down Expand Up @@ -2207,7 +2205,7 @@ async function preparePackage(module: string, useCache = true) {
}

const packageRoot = findPackageRoot(module);
await new Promise((ok, ko) => {
await new Promise<void>((ok, ko) => {
const child = childProcess.spawn('npm', ['pack', packageRoot], {
cwd: staging,
shell: true,
Expand Down
1 change: 0 additions & 1 deletion packages/jsii-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion packages/jsii-diff/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 4 additions & 4 deletions packages/jsii-diff/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
1 change: 0 additions & 1 deletion packages/jsii/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 3972932

Please sign in to comment.