Skip to content

Commit 2675ed3

Browse files
authored
chore(jest): use custom tsconfig for running tests (#3161)
1 parent 3fbbab2 commit 2675ed3

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

jest.config.base.js

+11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1+
const { compilerOptions } = require("@tsconfig/recommended/tsconfig.json");
2+
13
module.exports = {
24
preset: "ts-jest",
35
testMatch: ["**/*.spec.ts", "!**/*.browser.spec.ts", "!**/*.integ.spec.ts"],
6+
globals: {
7+
"ts-jest": {
8+
tsconfig: {
9+
...compilerOptions,
10+
noImplicitAny: false,
11+
strictNullChecks: false,
12+
},
13+
},
14+
},
415
};

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"@commitlint/cli": "^11.0.0",
5656
"@commitlint/config-conventional": "^11.0.0",
5757
"@mixer/parallel-prettier": "^2.0.1",
58+
"@tsconfig/recommended": "1.0.1",
5859
"@types/chai-as-promised": "^7.1.2",
5960
"@types/fs-extra": "^8.0.1",
6061
"@types/jest": "27.4.0",

packages/credential-providers/src/fromTemporaryCredentials.spec.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
const sendMock = jest.fn();
22
jest.mock("@aws-sdk/client-sts", () => ({
3-
STSClient: jest.fn().mockImplementation(function (config) {
4-
this.config = config;
5-
this.send = jest.fn().mockImplementation(async function (command) {
3+
STSClient: jest.fn().mockImplementation((config) => ({
4+
config,
5+
send: jest.fn().mockImplementation(async function (command) {
66
// Mock resolving client credentials provider at send()
7-
if (typeof this.config.credentials === "function") this.config.credentials = await this.config.credentials();
7+
if (typeof config.credentials === "function") config.credentials = await config.credentials();
88
return await sendMock(command);
9-
});
10-
return this;
11-
}),
9+
}),
10+
})),
1211
AssumeRoleCommand: jest.fn().mockImplementation(function (params) {
1312
// Return the input so we can assert the input parameters in client's send()
1413
return {

yarn.lock

+5
Original file line numberDiff line numberDiff line change
@@ -1938,6 +1938,11 @@
19381938
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
19391939
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==
19401940

1941+
"@tsconfig/[email protected]":
1942+
version "1.0.1"
1943+
resolved "https://registry.yarnpkg.com/@tsconfig/recommended/-/recommended-1.0.1.tgz#7619bad397e06ead1c5182926c944e0ca6177f52"
1944+
integrity sha512-2xN+iGTbPBEzGSnVp/Hd64vKJCJWxsi9gfs88x4PPMyEjHJoA3o5BY9r5OLPHIZU2pAQxkSAsJFqn6itClP8mQ==
1945+
19411946
"@types/babel__core@^7.0.0":
19421947
version "7.1.14"
19431948
resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.14.tgz#faaeefc4185ec71c389f4501ee5ec84b170cc402"

0 commit comments

Comments
 (0)