Skip to content

Commit

Permalink
Add the same changes to aws-cdk-lib.
Browse files Browse the repository at this point in the history
  • Loading branch information
skinny85 committed Nov 26, 2020
1 parent 786a46b commit 99c4666
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/aws-cdk-lib/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@ dist
# Ignore barrel import entry points
/*.ts

junit.xml
junit.xml

.nyc_output
coverage
nyc.config.js
!jest.config.js
!jest.setup.local.js
2 changes: 2 additions & 0 deletions packages/aws-cdk-lib/.npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ tsconfig.json
# exclude cdk artifacts
**/cdk.out
junit.xml
jest.config.js
jest.setup.local.js
5 changes: 5 additions & 0 deletions packages/aws-cdk-lib/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const baseConfig = require('cdk-build-tools/config/jest.config');
// no point in collecting coverage for aws-cdk-lib
baseConfig.collectCoverage = false;
baseConfig.setupFiles = ['./jest.setup.local.js'];
module.exports = baseConfig;
6 changes: 6 additions & 0 deletions packages/aws-cdk-lib/jest.setup.local.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// disallow tests (and production code) in aws-cdk-lib from including the @aws-cdk/core module,
// which effectively bans using any @aws-cdk/* module,
// as they all depend on @aws-cdk/core
jest.mock('@aws-cdk/core', () => {
throw new Error('@aws-cdk/core is not available in aws-cdk-lib tests!')
});
6 changes: 4 additions & 2 deletions packages/aws-cdk-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"stability": "experimental",
"maturity": "developer-preview",
"scripts": {
"gen": "ubergen",
"gen": "ubergen && cfn-include-mapping-rewriter lib/cloudformation-include aws-cdk-lib",
"build": "cdk-build",
"lint": "cdk-lint",
"test": "echo done",
"test": "cdk-test",
"package": "cdk-package",
"pkglint": "pkglint -f",
"build+test": "npm run build && npm test",
Expand All @@ -30,6 +30,7 @@
]
},
"cdk-build": {
"jest": true,
"eslint": {
"disable": true
}
Expand Down Expand Up @@ -270,6 +271,7 @@
"@types/fs-extra": "^8.1.1",
"@types/node": "^10.17.47",
"cdk-build-tools": "0.0.0",
"cfn-include-mapping-rewriter": "0.0.0",
"constructs": "^3.2.0",
"fs-extra": "^9.0.1",
"pkglint": "0.0.0",
Expand Down
13 changes: 13 additions & 0 deletions packages/aws-cdk-lib/test/cfn-include/cfn-include.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import * as cfn_inc from '../../cloudformation-include';
import * as s3 from '../../aws-s3';
import { Stack } from '../../lib';

test('cloudformation-include works in aws-cdk-lib', () => {
const stack = new Stack();
const cfnInclude = new cfn_inc.CfnInclude(stack, 'Template', {
templateFile: `${__dirname}/minimal-template.json`
});
const cfnBucket = cfnInclude.getResource('Bucket') as s3.CfnBucket;

expect(cfnBucket.bucketName).toEqual('my-bucket');
});
10 changes: 10 additions & 0 deletions packages/aws-cdk-lib/test/cfn-include/minimal-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Resources": {
"Bucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
"BucketName": "my-bucket"
}
}
}
}

0 comments on commit 99c4666

Please sign in to comment.