-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added Jest Tests to lib Template (#3948)
- Loading branch information
1 parent
77105ab
commit 9db7fff
Showing
13 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/aws-cdk/lib/init-templates/app/typescript/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/test" | ||
], | ||
testMatch: [ '**/*.test.ts'], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
packages/aws-cdk/lib/init-templates/app/typescript/test/%name%.test.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { expect as expectCDK, matchTemplate, MatchStyle } from '@aws-cdk/assert'; | ||
import cdk = require('@aws-cdk/core'); | ||
import %name.PascalCased% = require('../lib/%name%-stack'); | ||
|
||
test('Empty Stack', () => { | ||
const app = new cdk.App(); | ||
// WHEN | ||
const stack = new %name.PascalCased%.%name.PascalCased%Stack(app, 'MyTestStack'); | ||
// THEN | ||
expectCDK(stack).to(matchTemplate({ | ||
"Resources": {} | ||
}, MatchStyle.EXACT)) | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
# Useful commands | ||
|
||
* `npm run build` compile typescript to js | ||
* `npm run test` perform the jest unit tests | ||
* `npm run watch` watch for changes and compile |
9 changes: 9 additions & 0 deletions
9
packages/aws-cdk/lib/init-templates/lib/typescript/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/test" | ||
], | ||
testMatch: [ '**/*.test.ts'], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/aws-cdk/lib/init-templates/lib/typescript/test/%name%.test.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect as expectCDK, haveResource, SynthUtils } from '@aws-cdk/assert'; | ||
import cdk = require('@aws-cdk/core'); | ||
import %name.PascalCased% = require('../lib/index'); | ||
|
||
test('SQS Queue Created', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, "TestStack"); | ||
// WHEN | ||
new %name.PascalCased%.%name.PascalCased%(stack, 'MyTestConstruct'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SQS::Queue")); | ||
}); | ||
|
||
test('SNS Topic Created', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, "TestStack"); | ||
// WHEN | ||
new %name.PascalCased%.%name.PascalCased%(stack, 'MyTestConstruct'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SNS::Topic")); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/aws-cdk/lib/init-templates/sample-app/typescript/jest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
"roots": [ | ||
"<rootDir>/test" | ||
], | ||
testMatch: [ '**/*.test.ts'], | ||
"transform": { | ||
"^.+\\.tsx?$": "ts-jest" | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
packages/aws-cdk/lib/init-templates/sample-app/typescript/test/%name%.test.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { expect as expectCDK, haveResource } from '@aws-cdk/assert'; | ||
import cdk = require('@aws-cdk/core'); | ||
import %name.PascalCased% = require('../lib/%name%-stack'); | ||
|
||
test('SQS Queue Created', () => { | ||
const app = new cdk.App(); | ||
// WHEN | ||
const stack = new %name.PascalCased%.%name.PascalCased%Stack(app, 'MyTestStack'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SQS::Queue",{ | ||
VisibilityTimeout: 300 | ||
})); | ||
}); | ||
|
||
test('SNS Topic Created', () => { | ||
const app = new cdk.App(); | ||
// WHEN | ||
const stack = new %name.PascalCased%.%name.PascalCased%Stack(app, 'MyTestStack'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SNS::Topic")); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters