-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Add Jest tests to JavaScript init templates (#4282)
The test target in these templates were previously not running tests or failing. Adresses #4027
- Loading branch information
1 parent
fff798c
commit 22a5ada
Showing
6 changed files
with
51 additions
and
12 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
# Useful commands | ||
|
||
* `npm run test` check javascript error using the typescript compiler | ||
* `npm run test:watch` watch for changes and check javascript error using the typescript compiler | ||
* `npm run test` perform the jest unit tests | ||
* `cdk deploy` deploy this stack to your default AWS account/region | ||
* `cdk diff` compare deployed stack with current state | ||
* `cdk synth` emits the synthesized CloudFormation template |
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/javascript/test/%name%.test.template.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,13 @@ | ||
const { expect, matchTemplate, MatchStyle } = require('@aws-cdk/assert'); | ||
const cdk = require('@aws-cdk/core'); | ||
const %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 | ||
expect(stack).to(matchTemplate({ | ||
"Resources": {} | ||
}, MatchStyle.EXACT)) | ||
}); |
3 changes: 1 addition & 2 deletions
3
packages/aws-cdk/lib/init-templates/sample-app/javascript/README.md
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,7 +1,6 @@ | ||
# Useful commands | ||
|
||
* `npm run test` check javascript error using the typescript compiler | ||
* `npm run test:watch` watch for changes and check javascript error using the typescript compiler | ||
* `npm run test` perform the jest unit tests | ||
* `cdk deploy` deploy this stack to your default AWS account/region | ||
* `cdk diff` compare deployed stack with current state | ||
* `cdk synth` emits the synthesized CloudFormation template |
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/javascript/test/%name%.test.template.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,21 @@ | ||
const { expect, haveResource } = require('@aws-cdk/assert'); | ||
const cdk = require('@aws-cdk/core'); | ||
const %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 | ||
expect(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 | ||
expect(stack).to(haveResource("AWS::SNS::Topic")); | ||
}); |