diff --git a/nx.json b/nx.json index e8872e82abceb..0f16627a5fba8 100644 --- a/nx.json +++ b/nx.json @@ -11,7 +11,8 @@ "!{workspaceRoot}/**/tsconfig.json", "!{workspaceRoot}/**/tsconfig.json", "!{workspaceRoot}/tsconfig.base.json", - "!{workspaceRoot}/**/tsconfig.tsbuildinfo" + "!{workspaceRoot}/**/tsconfig.tsbuildinfo", + "!{workspaceRoot}/**/jest.config.js" ], "outputs": [ "{projectRoot}/**/*.integ.*.js.snapshot/*", diff --git a/package.json b/package.json index 4a73b88fdb3e4..7f47d899d71fd 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "jsii-pacmak": "1.87.0", "jsii-reflect": "1.87.0", "jsii-rosetta": "~5.1.10", + "ts-jest": "^29.1.1", "lerna": "^7.1.5", "nx": "^16.7.3", "patch-package": "^6.5.1", diff --git a/packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts b/packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts index 02a2c3d6c4feb..7fd9d3134f62e 100644 --- a/packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts +++ b/packages/@aws-cdk-testing/cli-integ/test/resource-pool.test.ts @@ -1,6 +1,8 @@ import { sleep } from '../lib'; import { ResourcePool } from '../lib/resource-pool'; +jest.setTimeout(30_000); + const POOL_NAME = 'resource-pool.test'; test('take and dispose', async () => { diff --git a/packages/@aws-cdk-testing/framework-integ/.gitignore b/packages/@aws-cdk-testing/framework-integ/.gitignore index 8ef66112140d5..4b8cda825f1bd 100644 --- a/packages/@aws-cdk-testing/framework-integ/.gitignore +++ b/packages/@aws-cdk-testing/framework-integ/.gitignore @@ -14,4 +14,6 @@ nyc.config.js !**/*.snapshot/**/asset.*/** -**/*.ts.snapshot \ No newline at end of file +**/*.ts.snapshot + +!jest.config.js diff --git a/packages/@aws-cdk-testing/framework-integ/jest.config.js b/packages/@aws-cdk-testing/framework-integ/jest.config.js new file mode 100644 index 0000000000000..2bf6c652c09dc --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/jest.config.js @@ -0,0 +1,14 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + // Purposely only run .js files, not .ts files. This is so that the unit tests + // here will use the jsii-compiled version of `aws-cdk-lib`, and not the live-interpreted + // .ts files. + moduleFileExtensions: [ + 'js', + ], + testMatch: [ + '/test/**/?(*.)+(test).js', + ], + + testEnvironment: 'node', +}; diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/__entrypoint__.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/__entrypoint__.js similarity index 100% rename from packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/__entrypoint__.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/__entrypoint__.js diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js new file mode 100644 index 0000000000000..dcca3af1f2fb5 --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js @@ -0,0 +1,18 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.CfnUtilsResourceType = void 0; +/** + * Supported resource type. + */ +var CfnUtilsResourceType; +(function (CfnUtilsResourceType) { + /** + * CfnJson + */ + CfnUtilsResourceType["CFN_JSON"] = "Custom::AWSCDKCfnJson"; + /** + * CfnJsonStringify + */ + CfnUtilsResourceType["CFN_JSON_STRINGIFY"] = "Custom::AWSCDKCfnJsonStringify"; +})(CfnUtilsResourceType || (exports.CfnUtilsResourceType = CfnUtilsResourceType = {})); +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY29uc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOztHQUVHO0FBQ0gsSUFBWSxvQkFVWDtBQVZELFdBQVksb0JBQW9CO0lBQzlCOztPQUVHO0lBQ0gsMERBQWtDLENBQUE7SUFFbEM7O09BRUc7SUFDSCw2RUFBcUQsQ0FBQTtBQUN2RCxDQUFDLEVBVlcsb0JBQW9CLG9DQUFwQixvQkFBb0IsUUFVL0IiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFN1cHBvcnRlZCByZXNvdXJjZSB0eXBlLlxuICovXG5leHBvcnQgZW51bSBDZm5VdGlsc1Jlc291cmNlVHlwZSB7XG4gIC8qKlxuICAgKiBDZm5Kc29uXG4gICAqL1xuICBDRk5fSlNPTiA9ICdDdXN0b206OkFXU0NES0Nmbkpzb24nLFxuXG4gIC8qKlxuICAgKiBDZm5Kc29uU3RyaW5naWZ5XG4gICAqL1xuICBDRk5fSlNPTl9TVFJJTkdJRlkgPSAnQ3VzdG9tOjpBV1NDREtDZm5Kc29uU3RyaW5naWZ5Jyxcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js new file mode 100644 index 0000000000000..a24d3cad7679f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.handler = void 0; +const consts_1 = require("./consts"); +/** + * Parses the value of "Value" and reflects it back as attribute. + */ +async function handler(event) { + // dispatch based on resource type + if (event.ResourceType === consts_1.CfnUtilsResourceType.CFN_JSON) { + return cfnJsonHandler(event); + } + if (event.ResourceType === consts_1.CfnUtilsResourceType.CFN_JSON_STRINGIFY) { + return cfnJsonStringifyHandler(event); + } + throw new Error(`unexpected resource type "${event.ResourceType}`); +} +exports.handler = handler; +function cfnJsonHandler(event) { + return { + Data: { + Value: JSON.parse(event.ResourceProperties.Value), + }, + }; +} +function cfnJsonStringifyHandler(event) { + return { + Data: { + Value: JSON.stringify(event.ResourceProperties.Value), + }, + }; +} +//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxxQ0FBZ0Q7QUFFaEQ7O0dBRUc7QUFDSSxLQUFLLFVBQVUsT0FBTyxDQUFDLEtBQWtEO0lBRTlFLGtDQUFrQztJQUNsQyxJQUFJLEtBQUssQ0FBQyxZQUFZLEtBQUssNkJBQW9CLENBQUMsUUFBUSxFQUFFO1FBQ3hELE9BQU8sY0FBYyxDQUFDLEtBQUssQ0FBQyxDQUFDO0tBQzlCO0lBQ0QsSUFBSSxLQUFLLENBQUMsWUFBWSxLQUFLLDZCQUFvQixDQUFDLGtCQUFrQixFQUFFO1FBQ2xFLE9BQU8sdUJBQXVCLENBQUMsS0FBSyxDQUFDLENBQUM7S0FDdkM7SUFFRCxNQUFNLElBQUksS0FBSyxDQUFDLDZCQUE2QixLQUFLLENBQUMsWUFBWSxFQUFFLENBQUMsQ0FBQztBQUNyRSxDQUFDO0FBWEQsMEJBV0M7QUFFRCxTQUFTLGNBQWMsQ0FBQyxLQUFrRDtJQUN4RSxPQUFPO1FBQ0wsSUFBSSxFQUFFO1lBQ0osS0FBSyxFQUFFLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLEtBQUssQ0FBQztTQUNsRDtLQUNGLENBQUM7QUFDSixDQUFDO0FBRUQsU0FBUyx1QkFBdUIsQ0FBQyxLQUFrRDtJQUNqRixPQUFPO1FBQ0wsSUFBSSxFQUFFO1lBQ0osS0FBSyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLEtBQUssQ0FBQztTQUN0RDtLQUNGLENBQUM7QUFDSixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ2ZuVXRpbHNSZXNvdXJjZVR5cGUgfSBmcm9tICcuL2NvbnN0cyc7XG5cbi8qKlxuICogUGFyc2VzIHRoZSB2YWx1ZSBvZiBcIlZhbHVlXCIgYW5kIHJlZmxlY3RzIGl0IGJhY2sgYXMgYXR0cmlidXRlLlxuICovXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gaGFuZGxlcihldmVudDogQVdTTGFtYmRhLkNsb3VkRm9ybWF0aW9uQ3VzdG9tUmVzb3VyY2VFdmVudCkge1xuXG4gIC8vIGRpc3BhdGNoIGJhc2VkIG9uIHJlc291cmNlIHR5cGVcbiAgaWYgKGV2ZW50LlJlc291cmNlVHlwZSA9PT0gQ2ZuVXRpbHNSZXNvdXJjZVR5cGUuQ0ZOX0pTT04pIHtcbiAgICByZXR1cm4gY2ZuSnNvbkhhbmRsZXIoZXZlbnQpO1xuICB9XG4gIGlmIChldmVudC5SZXNvdXJjZVR5cGUgPT09IENmblV0aWxzUmVzb3VyY2VUeXBlLkNGTl9KU09OX1NUUklOR0lGWSkge1xuICAgIHJldHVybiBjZm5Kc29uU3RyaW5naWZ5SGFuZGxlcihldmVudCk7XG4gIH1cblxuICB0aHJvdyBuZXcgRXJyb3IoYHVuZXhwZWN0ZWQgcmVzb3VyY2UgdHlwZSBcIiR7ZXZlbnQuUmVzb3VyY2VUeXBlfWApO1xufVxuXG5mdW5jdGlvbiBjZm5Kc29uSGFuZGxlcihldmVudDogQVdTTGFtYmRhLkNsb3VkRm9ybWF0aW9uQ3VzdG9tUmVzb3VyY2VFdmVudCkge1xuICByZXR1cm4ge1xuICAgIERhdGE6IHtcbiAgICAgIFZhbHVlOiBKU09OLnBhcnNlKGV2ZW50LlJlc291cmNlUHJvcGVydGllcy5WYWx1ZSksXG4gICAgfSxcbiAgfTtcbn1cblxuZnVuY3Rpb24gY2ZuSnNvblN0cmluZ2lmeUhhbmRsZXIoZXZlbnQ6IEFXU0xhbWJkYS5DbG91ZEZvcm1hdGlvbkN1c3RvbVJlc291cmNlRXZlbnQpIHtcbiAgcmV0dXJuIHtcbiAgICBEYXRhOiB7XG4gICAgICBWYWx1ZTogSlNPTi5zdHJpbmdpZnkoZXZlbnQuUmVzb3VyY2VQcm9wZXJ0aWVzLlZhbHVlKSxcbiAgICB9LFxuICB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/consts.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/consts.js deleted file mode 100644 index 872271a1fb7ef..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/consts.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY29uc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiIiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFN1cHBvcnRlZCByZXNvdXJjZSB0eXBlLlxuICovXG5leHBvcnQgY29uc3QgZW51bSBDZm5VdGlsc1Jlc291cmNlVHlwZSB7XG4gIC8qKlxuICAgKiBDZm5Kc29uXG4gICAqL1xuICBDRk5fSlNPTiA9ICdDdXN0b206OkFXU0NES0Nmbkpzb24nLFxuXG4gIC8qKlxuICAgKiBDZm5Kc29uU3RyaW5naWZ5XG4gICAqL1xuICBDRk5fSlNPTl9TVFJJTkdJRlkgPSAnQ3VzdG9tOjpBV1NDREtDZm5Kc29uU3RyaW5naWZ5Jyxcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/index.js deleted file mode 100644 index 269994454b057..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8/index.js +++ /dev/null @@ -1,32 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -/** - * Parses the value of "Value" and reflects it back as attribute. - */ -async function handler(event) { - // dispatch based on resource type - if (event.ResourceType === "Custom::AWSCDKCfnJson" /* CfnUtilsResourceType.CFN_JSON */) { - return cfnJsonHandler(event); - } - if (event.ResourceType === "Custom::AWSCDKCfnJsonStringify" /* CfnUtilsResourceType.CFN_JSON_STRINGIFY */) { - return cfnJsonStringifyHandler(event); - } - throw new Error(`unexpected resource type "${event.ResourceType}`); -} -exports.handler = handler; -function cfnJsonHandler(event) { - return { - Data: { - Value: JSON.parse(event.ResourceProperties.Value), - }, - }; -} -function cfnJsonStringifyHandler(event) { - return { - Data: { - Value: JSON.stringify(event.ResourceProperties.Value), - }, - }; -} -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJpbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFFQTs7R0FFRztBQUNJLEtBQUssVUFBVSxPQUFPLENBQUMsS0FBa0Q7SUFFOUUsa0NBQWtDO0lBQ2xDLElBQUksS0FBSyxDQUFDLFlBQVksZ0VBQWtDLEVBQUU7UUFDeEQsT0FBTyxjQUFjLENBQUMsS0FBSyxDQUFDLENBQUM7S0FDOUI7SUFDRCxJQUFJLEtBQUssQ0FBQyxZQUFZLG1GQUE0QyxFQUFFO1FBQ2xFLE9BQU8sdUJBQXVCLENBQUMsS0FBSyxDQUFDLENBQUM7S0FDdkM7SUFFRCxNQUFNLElBQUksS0FBSyxDQUFDLDZCQUE2QixLQUFLLENBQUMsWUFBWSxFQUFFLENBQUMsQ0FBQztBQUNyRSxDQUFDO0FBWEQsMEJBV0M7QUFFRCxTQUFTLGNBQWMsQ0FBQyxLQUFrRDtJQUN4RSxPQUFPO1FBQ0wsSUFBSSxFQUFFO1lBQ0osS0FBSyxFQUFFLElBQUksQ0FBQyxLQUFLLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLEtBQUssQ0FBQztTQUNsRDtLQUNGLENBQUM7QUFDSixDQUFDO0FBRUQsU0FBUyx1QkFBdUIsQ0FBQyxLQUFrRDtJQUNqRixPQUFPO1FBQ0wsSUFBSSxFQUFFO1lBQ0osS0FBSyxFQUFFLElBQUksQ0FBQyxTQUFTLENBQUMsS0FBSyxDQUFDLGtCQUFrQixDQUFDLEtBQUssQ0FBQztTQUN0RDtLQUNGLENBQUM7QUFDSixDQUFDIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IHsgQ2ZuVXRpbHNSZXNvdXJjZVR5cGUgfSBmcm9tICcuL2NvbnN0cyc7XG5cbi8qKlxuICogUGFyc2VzIHRoZSB2YWx1ZSBvZiBcIlZhbHVlXCIgYW5kIHJlZmxlY3RzIGl0IGJhY2sgYXMgYXR0cmlidXRlLlxuICovXG5leHBvcnQgYXN5bmMgZnVuY3Rpb24gaGFuZGxlcihldmVudDogQVdTTGFtYmRhLkNsb3VkRm9ybWF0aW9uQ3VzdG9tUmVzb3VyY2VFdmVudCkge1xuXG4gIC8vIGRpc3BhdGNoIGJhc2VkIG9uIHJlc291cmNlIHR5cGVcbiAgaWYgKGV2ZW50LlJlc291cmNlVHlwZSA9PT0gQ2ZuVXRpbHNSZXNvdXJjZVR5cGUuQ0ZOX0pTT04pIHtcbiAgICByZXR1cm4gY2ZuSnNvbkhhbmRsZXIoZXZlbnQpO1xuICB9XG4gIGlmIChldmVudC5SZXNvdXJjZVR5cGUgPT09IENmblV0aWxzUmVzb3VyY2VUeXBlLkNGTl9KU09OX1NUUklOR0lGWSkge1xuICAgIHJldHVybiBjZm5Kc29uU3RyaW5naWZ5SGFuZGxlcihldmVudCk7XG4gIH1cblxuICB0aHJvdyBuZXcgRXJyb3IoYHVuZXhwZWN0ZWQgcmVzb3VyY2UgdHlwZSBcIiR7ZXZlbnQuUmVzb3VyY2VUeXBlfWApO1xufVxuXG5mdW5jdGlvbiBjZm5Kc29uSGFuZGxlcihldmVudDogQVdTTGFtYmRhLkNsb3VkRm9ybWF0aW9uQ3VzdG9tUmVzb3VyY2VFdmVudCkge1xuICByZXR1cm4ge1xuICAgIERhdGE6IHtcbiAgICAgIFZhbHVlOiBKU09OLnBhcnNlKGV2ZW50LlJlc291cmNlUHJvcGVydGllcy5WYWx1ZSksXG4gICAgfSxcbiAgfTtcbn1cblxuZnVuY3Rpb24gY2ZuSnNvblN0cmluZ2lmeUhhbmRsZXIoZXZlbnQ6IEFXU0xhbWJkYS5DbG91ZEZvcm1hdGlvbkN1c3RvbVJlc291cmNlRXZlbnQpIHtcbiAgcmV0dXJuIHtcbiAgICBEYXRhOiB7XG4gICAgICBWYWx1ZTogSlNPTi5zdHJpbmdpZnkoZXZlbnQuUmVzb3VyY2VQcm9wZXJ0aWVzLlZhbHVlKSxcbiAgICB9LFxuICB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out index f0b901e7c06e5..560dae10d018f 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"32.0.0"} \ No newline at end of file +{"version":"33.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json index 6429d0f72d991..b043af1a3d904 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json index ecfc59ddb7215..2f04f2aac279c 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json @@ -1,10 +1,11 @@ { - "version": "32.0.0", + "version": "33.0.0", "testCases": { "iam-test-condition-with-ref/DefaultTest": { "stacks": [ "test-condition-with-ref" ], + "diffAssets": true, "assertionStack": "iam-test-condition-with-ref/DefaultTest/DeployAssert", "assertionStackName": "iamtestconditionwithrefDefaultTestDeployAssert5E44A64B" } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json index fcecae584dace..c11acef43c3fc 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "32.0.0", + "version": "33.0.0", "artifacts": { "test-condition-with-ref.assets": { "type": "cdk:asset-manifest", @@ -17,7 +17,7 @@ "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/5d543b44583359346e7d4e1d73209c742ec533540ce929f2f2493fb27b0e738d.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json index 173b4a42636c3..3f6d7f5a53918 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json @@ -1,20 +1,20 @@ { - "version": "32.0.0", + "version": "33.0.0", "files": { - "a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8": { + "1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde": { "source": { - "path": "asset.a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8", + "path": "asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8.zip", + "objectKey": "1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "5d543b44583359346e7d4e1d73209c742ec533540ce929f2f2493fb27b0e738d": { + "c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc": { "source": { "path": "test-condition-with-ref.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "5d543b44583359346e7d4e1d73209c742ec533540ce929f2f2493fb27b0e738d.json", + "objectKey": "c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json index 79406296343f6..58e9598bae22b 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json @@ -65,7 +65,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "a913a2614f4e118cb83fa3c0dd17575c9adbbdbad4da17aecd505282a25513f8.zip" + "S3Key": "1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde.zip" }, "Timeout": 900, "MemorySize": 128, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json index 9ef9d28272280..ad8cf02d25aa4 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json @@ -179,7 +179,7 @@ "path": "iam-test-condition-with-ref/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } }, "DeployAssert": { @@ -225,7 +225,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.55" + "version": "10.2.69" } } }, diff --git a/packages/aws-cdk-lib/core/test/runtime-info.test.ts b/packages/@aws-cdk-testing/framework-integ/test/core/test/runtime-info.test.ts similarity index 89% rename from packages/aws-cdk-lib/core/test/runtime-info.test.ts rename to packages/@aws-cdk-testing/framework-integ/test/core/test/runtime-info.test.ts index 12597c184ce7b..c9efc6785a237 100644 --- a/packages/aws-cdk-lib/core/test/runtime-info.test.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/core/test/runtime-info.test.ts @@ -1,8 +1,11 @@ +/** + * Unit tests that depend on 'aws-cdk-lib' having been compiled using jsii + */ import * as fs from 'fs'; import * as path from 'path'; import { Construct } from 'constructs'; -import { App, NestedStack, Stack, Stage, IPolicyValidationPluginBeta1, PolicyViolationBeta1, PolicyValidationPluginReportBeta1, IPolicyValidationContextBeta1 } from '../lib'; -import { constructInfoFromConstruct, constructInfoFromStack } from '../lib/private/runtime-info'; +import { App, NestedStack, Stack, Stage, IPolicyValidationPluginBeta1, PolicyViolationBeta1, PolicyValidationPluginReportBeta1, IPolicyValidationContextBeta1 } from 'aws-cdk-lib'; +import { constructInfoFromConstruct, constructInfoFromStack } from 'aws-cdk-lib/core/lib/helpers-internal'; const JSII_RUNTIME_SYMBOL = Symbol.for('jsii.rtti'); @@ -10,23 +13,6 @@ let app: App; let stack: Stack; let _cdkVersion: string | undefined = undefined; -// The runtime metadata this test relies on is only available if the most -// recent compile has happened using 'jsii', as the jsii compiler injects -// this metadata. -// -// If the most recent compile was using 'tsc', the metadata will not have -// been injected, and the test suite will fail. -// -// Tolerate `tsc` builds locally, but not on CodeBuild. -const codeBuild = !!process.env.CODEBUILD_BUILD_ID; -const moduleCompiledWithTsc = constructInfoFromConstruct(new Stack())?.fqn === 'constructs.Construct'; -let describeTscSafe = describe; -if (moduleCompiledWithTsc && !codeBuild) { - // eslint-disable-next-line - console.error('It appears this module was compiled with `tsc` instead of `jsii` in a local build. Skipping this test suite.'); - describeTscSafe = describe.skip; -} - beforeEach(() => { app = new App(); stack = new Stack(app, 'Stack', { @@ -34,7 +20,7 @@ beforeEach(() => { }); }); -describeTscSafe('constructInfoFromConstruct', () => { +describe('constructInfoFromConstruct', () => { test('returns fqn and version for core constructs', () => { const constructInfo = constructInfoFromConstruct(stack); expect(constructInfo).toBeDefined(); @@ -70,7 +56,7 @@ describeTscSafe('constructInfoFromConstruct', () => { }); }); -describeTscSafe('constructInfoForStack', () => { +describe('constructInfoForStack', () => { test('returns stack itself and jsii runtime if stack is empty', () => { const constructInfos = constructInfoFromStack(stack); diff --git a/packages/aws-cdk-lib/core/test/private/tree-metadata.test.ts b/packages/@aws-cdk-testing/framework-integ/test/core/test/tree-metadata.test.ts similarity index 97% rename from packages/aws-cdk-lib/core/test/private/tree-metadata.test.ts rename to packages/@aws-cdk-testing/framework-integ/test/core/test/tree-metadata.test.ts index 482cc6301b833..68eeb6786e7ef 100644 --- a/packages/aws-cdk-lib/core/test/private/tree-metadata.test.ts +++ b/packages/@aws-cdk-testing/framework-integ/test/core/test/tree-metadata.test.ts @@ -1,8 +1,11 @@ +/** + * Unit tests that depend on 'aws-cdk-lib' having been compiled using jsii + */ import * as fs from 'fs'; import * as path from 'path'; import { Construct } from 'constructs'; -import * as cxschema from '../../../cloud-assembly-schema'; -import { App, CfnParameter, CfnResource, Lazy, Stack, TreeInspector } from '../../lib/index'; +import * as cxschema from 'aws-cdk-lib/cloud-assembly-schema'; +import { App, CfnParameter, CfnResource, Lazy, Stack, TreeInspector } from 'aws-cdk-lib'; abstract class AbstractCfnResource extends CfnResource { constructor(scope: Construct, id: string) { @@ -160,21 +163,19 @@ describe('tree metadata', () => { const treeArtifact = assembly.tree(); expect(treeArtifact).toBeDefined(); - const codeBuild = !!process.env.CODEBUILD_BUILD_ID; - expect(readJson(assembly.directory, treeArtifact!.file)).toEqual({ version: 'tree-0.1', tree: expect.objectContaining({ children: expect.objectContaining({ mystack: expect.objectContaining({ constructInfo: { - fqn: expect.stringMatching(codeBuild ? /\bStack$/ : /\bStack$|^constructs.Construct$/), + fqn: expect.stringMatching(/\bStack$/), version: expect.any(String), }, children: expect.objectContaining({ myconstruct: expect.objectContaining({ constructInfo: { - fqn: expect.stringMatching(codeBuild ? /\bCfnResource$/ : /\bCfnResource$|^constructs.Construct$/), + fqn: expect.stringMatching(/\bCfnResource$/), version: expect.any(String), }, }), @@ -398,4 +399,4 @@ describe('tree metadata', () => { function readJson(outdir: string, file: string) { return JSON.parse(fs.readFileSync(path.join(outdir, file), 'utf-8')); -} +} \ No newline at end of file diff --git a/packages/@aws-cdk/app-staging-synthesizer-alpha/test/app-staging-synthesizer.test.ts b/packages/@aws-cdk/app-staging-synthesizer-alpha/test/app-staging-synthesizer.test.ts index 3e6504b7befe9..c3a8d96299b8b 100644 --- a/packages/@aws-cdk/app-staging-synthesizer-alpha/test/app-staging-synthesizer.test.ts +++ b/packages/@aws-cdk/app-staging-synthesizer-alpha/test/app-staging-synthesizer.test.ts @@ -137,7 +137,7 @@ describe(AppStagingSynthesizer, () => { // THEN - we have a fixed asset location expect(evalCFN(location.bucketName)).toEqual(`cdk-${APP_ID}-staging-000000000000-us-east-1`); - expect(evalCFN(location.httpUrl)).toEqual(`https://s3.us-east-1.domain.aws/cdk-${APP_ID}-staging-000000000000-us-east-1/abcdef.js`); + expect(evalCFN(location.httpUrl)).toEqual(`https://s3.us-east-1.domain.aws/cdk-${APP_ID}-staging-000000000000-us-east-1/abcdef.ts`); // THEN - object key contains source hash somewhere expect(location.objectKey.indexOf('abcdef')).toBeGreaterThan(-1); @@ -187,7 +187,7 @@ describe(AppStagingSynthesizer, () => { }); // THEN - asset has deploy time prefix - expect(evalCFN(location.objectKey)).toEqual(`${DEPLOY_TIME_PREFIX}abcdef.js`); + expect(evalCFN(location.objectKey)).toEqual(`${DEPLOY_TIME_PREFIX}abcdef.ts`); }); test('lambda assets are by default deploy time assets', () => { diff --git a/packages/@aws-cdk/aws-msk-alpha/test/__snapshots__/cluster.test.js.snap b/packages/@aws-cdk/aws-msk-alpha/test/__snapshots__/cluster.test.ts.snap similarity index 100% rename from packages/@aws-cdk/aws-msk-alpha/test/__snapshots__/cluster.test.js.snap rename to packages/@aws-cdk/aws-msk-alpha/test/__snapshots__/cluster.test.ts.snap diff --git a/packages/@aws-cdk/cloud-assembly-schema/jest.config.js b/packages/@aws-cdk/cloud-assembly-schema/jest.config.js index 1700f0873cc01..b128c97cea054 100644 --- a/packages/@aws-cdk/cloud-assembly-schema/jest.config.js +++ b/packages/@aws-cdk/cloud-assembly-schema/jest.config.js @@ -1,11 +1,6 @@ const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); module.exports = { ...baseConfig, - moduleFileExtensions: [ - 'js', - 'ts', - ], - preset: 'ts-jest', testMatch: [ '/**/test/**/?(*.)+(test).ts', ], diff --git a/packages/@aws-cdk/cx-api/jest.config.js b/packages/@aws-cdk/cx-api/jest.config.js index 37c818dbced5f..f4f042f9d2c29 100644 --- a/packages/@aws-cdk/cx-api/jest.config.js +++ b/packages/@aws-cdk/cx-api/jest.config.js @@ -1,14 +1,6 @@ const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); module.exports = { - ...baseConfig, - moduleFileExtensions: [ - 'js', - 'ts', - ], - preset: 'ts-jest', - testMatch: [ - '/**/test/**/?(*.)+(test).ts', - ], + ...baseConfig, coverageThreshold: { global: { ...baseConfig.coverageThreshold.global, diff --git a/packages/@aws-cdk/region-info/jest.config.js b/packages/@aws-cdk/region-info/jest.config.js index 036d2133dfe23..a5faeee256594 100644 --- a/packages/@aws-cdk/region-info/jest.config.js +++ b/packages/@aws-cdk/region-info/jest.config.js @@ -1,11 +1,6 @@ const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); module.exports = { ...baseConfig, - moduleFileExtensions: [ - 'js', - 'ts', - ], - preset: 'ts-jest', testMatch: [ '/**/test/**/?(*.)+(test).ts', ], diff --git a/packages/aws-cdk-lib/aws-apigateway/lib/usage-plan.ts b/packages/aws-cdk-lib/aws-apigateway/lib/usage-plan.ts index 7cc2957da8a7a..920d1099ecfbb 100644 --- a/packages/aws-cdk-lib/aws-apigateway/lib/usage-plan.ts +++ b/packages/aws-cdk-lib/aws-apigateway/lib/usage-plan.ts @@ -79,7 +79,7 @@ export interface ThrottlingPerMethod { /** * Type of Usage Plan Key. Currently the only supported type is 'ApiKey' */ -const enum UsagePlanKeyType { +enum UsagePlanKeyType { API_KEY = 'API_KEY' } diff --git a/packages/aws-cdk-lib/aws-ecr/lib/repository.ts b/packages/aws-cdk-lib/aws-ecr/lib/repository.ts index cddc3e1e42f4b..39bdb24eca355 100644 --- a/packages/aws-cdk-lib/aws-ecr/lib/repository.ts +++ b/packages/aws-cdk-lib/aws-ecr/lib/repository.ts @@ -937,7 +937,7 @@ function renderLifecycleRule(rule: LifecycleRule) { /** * Select images based on counts */ -const enum CountType { +enum CountType { /** * Set a limit on the number of images in your repository */ diff --git a/packages/aws-cdk-lib/core/lib/helpers-internal/index.ts b/packages/aws-cdk-lib/core/lib/helpers-internal/index.ts index bc3f28e0107bb..03a39234e8d52 100644 --- a/packages/aws-cdk-lib/core/lib/helpers-internal/index.ts +++ b/packages/aws-cdk-lib/core/lib/helpers-internal/index.ts @@ -2,4 +2,5 @@ export * from './cfn-parse'; // Other libraries are going to need this as well export { md5hash } from '../private/md5'; export * from './customize-roles'; -export * from './string-specializer'; \ No newline at end of file +export * from './string-specializer'; +export { constructInfoFromConstruct, constructInfoFromStack } from '../private/runtime-info'; \ No newline at end of file diff --git a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts index 9718dcef40645..31417563a1736 100644 --- a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts +++ b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts @@ -1,7 +1,7 @@ /** * Supported resource type. */ -export const enum CfnUtilsResourceType { +export enum CfnUtilsResourceType { /** * CfnJson */ diff --git a/packages/aws-cdk-lib/core/test/stack-synthesis/clicreds-synthesis.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesis/clicreds-synthesis.test.ts index b47e65ba74f62..c688431df804c 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesis/clicreds-synthesis.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesis/clicreds-synthesis.test.ts @@ -56,6 +56,7 @@ describe('CLI creds synthesis', () => { test('add file asset', () => { // WHEN + const ext = __filename.match(/\.([tj]s)$/)?.[1]; const location = stack.synthesizer.addFileAsset({ fileName: __filename, packaging: FileAssetPackaging.FILE, @@ -64,7 +65,7 @@ describe('CLI creds synthesis', () => { // THEN - we have a fixed asset location with region placeholders expect(evalCFN(location.bucketName)).toEqual('cdk-hnb659fds-assets-the_account-the_region'); - expect(evalCFN(location.s3Url)).toEqual('https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef.ts'); + expect(evalCFN(location.s3Url)).toEqual(`https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef.${ext}`); // THEN - object key contains source hash somewhere expect(location.objectKey.indexOf('abcdef')).toBeGreaterThan(-1); @@ -118,6 +119,7 @@ describe('CLI creds synthesis', () => { }), }); + const ext = __filename.match(/\.([tj]s)$/)?.[1]; mystack.synthesizer.addFileAsset({ fileName: __filename, packaging: FileAssetPackaging.FILE, @@ -135,7 +137,7 @@ describe('CLI creds synthesis', () => { expect(manifest.files?.['file-asset-hash']?.destinations?.['current_account-current_region']).toEqual({ bucketName: 'file-asset-bucket', - objectKey: 'file-asset-hash.ts', + objectKey: `file-asset-hash.${ext}`, }); expect(manifest.dockerImages?.['docker-asset-hash']?.destinations?.['current_account-current_region']).toEqual({ @@ -156,6 +158,7 @@ describe('CLI creds synthesis', () => { }), }); + const ext = __filename.match(/\.([tj]s)$/)?.[1]; mystack.synthesizer.addFileAsset({ fileName: __filename, packaging: FileAssetPackaging.FILE, @@ -174,7 +177,7 @@ describe('CLI creds synthesis', () => { // THEN expect(manifest.files?.['file-asset-hash-with-prefix']?.destinations?.['current_account-current_region']).toEqual({ bucketName: 'file-asset-bucket', - objectKey: '000000000000/file-asset-hash-with-prefix.ts', + objectKey: `000000000000/file-asset-hash-with-prefix.${ext}`, }); const templateHash = last(stackArtifact.stackTemplateAssetObjectUrl?.split('/')); diff --git a/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts b/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts index 6c8fee21b79fd..f39c577d82be9 100644 --- a/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts +++ b/packages/aws-cdk-lib/core/test/stack-synthesis/new-style-synthesis.test.ts @@ -208,6 +208,7 @@ describe('new style synthesis', () => { test('add file asset', () => { // WHEN + const ext = __filename.match(/\.([tj]s)$/)?.[1]; const location = stack.synthesizer.addFileAsset({ fileName: __filename, packaging: FileAssetPackaging.FILE, @@ -216,7 +217,7 @@ describe('new style synthesis', () => { // THEN - we have a fixed asset location with region placeholders expect(evalCFN(location.bucketName)).toEqual('cdk-hnb659fds-assets-the_account-the_region'); - expect(evalCFN(location.s3Url)).toEqual('https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef.ts'); + expect(evalCFN(location.s3Url)).toEqual(`https://s3.the_region.domain.aws/cdk-hnb659fds-assets-the_account-the_region/abcdef.${ext}`); // THEN - object key contains source hash somewhere expect(location.objectKey.indexOf('abcdef')).toBeGreaterThan(-1); @@ -314,6 +315,7 @@ describe('new style synthesis', () => { }), }); + const ext = __filename.match(/\.([tj]s)$/)?.[1]; mystack.synthesizer.addFileAsset({ fileName: __filename, packaging: FileAssetPackaging.FILE, @@ -331,7 +333,7 @@ describe('new style synthesis', () => { expect(manifest.files?.['file-asset-hash']?.destinations?.['current_account-current_region']).toEqual({ bucketName: 'file-asset-bucket', - objectKey: 'file-asset-hash.ts', + objectKey: `file-asset-hash.${ext}`, assumeRoleArn: 'file:role:arn', assumeRoleExternalId: 'file-external-id', }); diff --git a/packages/aws-cdk-lib/jest.config.js b/packages/aws-cdk-lib/jest.config.js index cea26228ba11f..a5d279d7bf4d0 100644 --- a/packages/aws-cdk-lib/jest.config.js +++ b/packages/aws-cdk-lib/jest.config.js @@ -1,22 +1,15 @@ const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); -const cpuCount = require('os').cpus().length; - /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { ...baseConfig, - moduleFileExtensions: [ - 'js', - 'ts', - ], - // Limit workers to a reasonable fixed number. If we scale in the number of available CPUs, we will explode - // our memory limit on the CodeBuild instance that has 72 CPUs. - maxWorkers: Math.min(8, cpuCount - 1), - preset: 'ts-jest', + + // Different than usual testMatch: [ '/**/test/**/?(*.)+(test).ts', ], - coverageThreshold: { + + coverageThreshold: { global: { branches: 35, statements: 55, diff --git a/packages/aws-cdk-lib/package.json b/packages/aws-cdk-lib/package.json index 389a95254e848..40b60a40d6469 100644 --- a/packages/aws-cdk-lib/package.json +++ b/packages/aws-cdk-lib/package.json @@ -125,8 +125,8 @@ ], "dependencies": { "@aws-cdk/asset-awscli-v1": "^2.2.200", - "@aws-cdk/asset-node-proxy-agent-v6": "^2.0.1", "@aws-cdk/asset-kubectl-v20": "^2.1.2", + "@aws-cdk/asset-node-proxy-agent-v6": "^2.0.1", "@balena/dockerignore": "^1.0.2", "case": "1.6.3", "fs-extra": "^11.1.1", @@ -183,9 +183,9 @@ "lambda-tester": "^4.0.1", "lodash": "^4.17.21", "nock": "^13.3.3", + "sinon": "^9.2.4", "ts-mock-imports": "^1.3.8", "ts-node": "^10.9.1", - "sinon": "^9.2.4", "typescript": "~5.1.6", "typescript-json-schema": "^0.59.0" }, diff --git a/packages/aws-cdk/test/assets.test.ts b/packages/aws-cdk/test/assets.test.ts index 366730bbb612a..e71942324f2f8 100644 --- a/packages/aws-cdk/test/assets.test.ts +++ b/packages/aws-cdk/test/assets.test.ts @@ -17,6 +17,7 @@ beforeEach(() => { describe('file assets', () => { test('convert to manifest and parameters', async () => { // GIVEN + const ext = __filename.match(/\.([tj]s)$/)?.[1]; const stack = stackWithAssets([ { sourceHash: 'source-hash', @@ -35,7 +36,7 @@ describe('file assets', () => { // THEN expect(params).toEqual({ BucketParameter: 'MockToolkitBucketName', - KeyParameter: 'assets/SomeStackSomeResource4567/||source-hash.js', + KeyParameter: `assets/SomeStackSomeResource4567/||source-hash.${ext}`, ArtifactHashParameter: 'source-hash', }); @@ -43,7 +44,7 @@ describe('file assets', () => { expect.objectContaining({ destination: { bucketName: 'MockToolkitBucketName', - objectKey: 'assets/SomeStackSomeResource4567/source-hash.js', + objectKey: `assets/SomeStackSomeResource4567/source-hash.${ext}`, }, source: { packaging: 'file', @@ -55,6 +56,7 @@ describe('file assets', () => { test('hash and ID the same => only one path component', async () => { // GIVEN + const ext = __filename.match(/\.([tj]s)$/)?.[1]; const stack = stackWithAssets([ { sourceHash: 'source-hash', @@ -75,7 +77,7 @@ describe('file assets', () => { expect.objectContaining({ destination: { bucketName: 'MockToolkitBucketName', - objectKey: 'assets/source-hash.js', + objectKey: `assets/source-hash.${ext}`, }, }), ]); diff --git a/tools/@aws-cdk/cdk-build-tools/config/jest.config.js b/tools/@aws-cdk/cdk-build-tools/config/jest.config.js index 1b907f3b6ffc6..6e41fa2e239bf 100644 --- a/tools/@aws-cdk/cdk-build-tools/config/jest.config.js +++ b/tools/@aws-cdk/cdk-build-tools/config/jest.config.js @@ -1,30 +1,48 @@ +const { cpus } = require('os'); + module.exports = { - moduleFileExtensions: [ - "js", + // The preset deals with preferring TS over JS + moduleFileExtensions: [ + // .ts first to prefer a ts over a js if present + 'ts', + 'js', + ], + testMatch: [ + '/test/**/?(*.)+(test).ts', + ], + + // Transform TypeScript using ts-jest. Use of this preset still requires the depending + // package to depend on `ts-jest` directly. + transform: { + '^.+\\.tsx?$': [ + 'ts-jest', + { + // Skips type checking + isolatedModules: true, + }, ], - testMatch: [ - "/test/**/?(*.)+(test).js", - ], - testEnvironment: "node", - coverageThreshold: { - global: { - branches: 80, - statements: 80, - }, + }, + + // Limit workers to a reasonable fixed number. If we scale in the number of available CPUs, we will explode + // our memory limit on the CodeBuild instance that has 72 CPUs. + maxWorkers: Math.min(8, cpus().length - 1), + + testEnvironment: 'node', + coverageThreshold: { + global: { + branches: 80, + statements: 80, }, - collectCoverage: true, - coverageReporters: [ - "lcov", - "html", - "text-summary", - ], - coveragePathIgnorePatterns: [ - "/lib/.*\\.generated\\.[jt]s", - "/test/.*\\.[jt]s", - "/.warnings.jsii.js", - ], - reporters: [ - "default", - [ "jest-junit", { suiteName: "jest tests", outputDirectory: "coverage" } ] - ] + }, + collectCoverage: true, + coverageReporters: ['lcov', 'html', 'text-summary'], + coveragePathIgnorePatterns: [ + '\\.generated\\.[jt]s$', + '/test/', + '.warnings.jsii.js$', + ], + reporters: [ + 'default', + ['jest-junit', { suiteName: 'jest tests', outputDirectory: 'coverage' }], + ], }; diff --git a/tools/@aws-cdk/cdk-build-tools/package.json b/tools/@aws-cdk/cdk-build-tools/package.json index 020745b34b6d2..0d17e33ab4a03 100644 --- a/tools/@aws-cdk/cdk-build-tools/package.json +++ b/tools/@aws-cdk/cdk-build-tools/package.json @@ -3,7 +3,6 @@ "private": true, "version": "0.0.0", "description": "Tools package with shared build scripts for CDK packages", - "main": "lib/index.js", "repository": { "type": "git", "url": "https://github.com/aws/aws-cdk.git", @@ -40,8 +39,10 @@ "@types/fs-extra": "^9.0.13", "@types/jest": "^29.5.4", "@types/semver": "^7.5.0", - "@types/yargs": "^15.0.15" + "@types/yargs": "^15.0.15", + "jest-resolve": "^29.6.3" }, + "main": "lib/index.js", "dependencies": { "@aws-cdk/eslint-plugin": "0.0.0", "@aws-cdk/yarn-cling": "0.0.0", diff --git a/tools/@aws-cdk/pkglint/jest.config.js b/tools/@aws-cdk/pkglint/jest.config.js index 7bb32293f74e2..3f4ba066475b7 100644 --- a/tools/@aws-cdk/pkglint/jest.config.js +++ b/tools/@aws-cdk/pkglint/jest.config.js @@ -1,5 +1,26 @@ +// Cannot depend on cdk-build-tools, cdk-build-tools depends on this module.exports = { - testMatch: [ - "**/?(*.)+(test).js", - ], + moduleFileExtensions: [ + "js", + ], + testMatch: [ + "**/?(*.)+(test).js", + ], + testEnvironment: "node", + coverageThreshold: { + global: { + branches: 10, + statements: 10, + }, + }, + collectCoverage: true, + coverageReporters: [ + "lcov", + "html", + "text-summary", + ], + coveragePathIgnorePatterns: [ + "/lib/.*\\.generated\\.[jt]s", + "/test/.*\\.[jt]s", + ], }; diff --git a/tools/@aws-cdk/spec2cdk/jest.config.js b/tools/@aws-cdk/spec2cdk/jest.config.js index 4999b9746e157..1a75d3f3b0092 100644 --- a/tools/@aws-cdk/spec2cdk/jest.config.js +++ b/tools/@aws-cdk/spec2cdk/jest.config.js @@ -2,10 +2,6 @@ const baseConfig = require('@aws-cdk/cdk-build-tools/config/jest.config'); module.exports = { ...baseConfig, - testMatch: [ - "**/?(*.)+(test).js", - ], - testEnvironment: 'node', coverageThreshold: { global: { // Pretty bad but we disabled snapshots