Welcome to AWS CDK remove identifers’s documentation!
This package contains the classes for managing the testing of your AWS CDK code.
Getting started
AWS CDK remove identifiers package is implemented for helping you to test your AWS CDK code.
The goal is to compare the previous template saved with the new template synthetized. By Jest, you can match by toMatchObject method your template synthetized by your TypeScript code with a template that you saved.
It is part of the educational repositories to learn how to write stardard code and common uses of the TDD.
Prerequisite
The package is not self-consistent: it needs to install npm, the Node Package Manager.
Installation
You can download the package by github:
$ git clone https://github.com/bilardi/aws-cdk-remove-identifiers
Or you can install by npm:
$ npm install aws-cdk-remove-identifiers
Read the documentation on readthedocs for
Usage
Development
Change Log
See CHANGELOG.md for details.
License
This package is released under the MIT license. See LICENSE for details.
Usage
The class reads a template synthesed by AWS CDK and returns it without identifiers.
You have to import the class removeIdentifiers before to use it.
import { RemoveIdentifiers } from "aws-cdk-remove-identifiers";
The class wants an object-type template like input and returns the same template without identifers.
const templateWithoutIdentifiers = new RemoveIdentifiers(templateWithIdentifiers);
Example
When you create your stack.ts file, you can create your stack.test.ts like the example in this repo. You can find
lib/removeIdentifiers.ts, the example of your class implemented
tests/removeIdentifiers.test.ts, the example of your unittest class
tests/*.json, the templates saved
When you run the unittest (see the Development Section),
before, you have to create a json file empty (ie: tests/templateWithoutIdentifiers.json)
the first time, you have to fill it with the first version (so, at the beginning the test fails and it returns the json)
the times after, if the templates saved and new are different, so the unittest fails, you can evaluate if you have to save a new version or fix your change
You can find real examples in the repositories below:
Development
This package is used only for testing your AWS CDK code, so it is useful for helping you to implement your TDD.
If you want to use this package with your AWS CDK code, you can find an example in the tests folder of this repository.
Run tests
cd aws-cdk-remove-identifiers/
make test # it also run other commands like npm install
Template saved
If the unittest fails, the class prints the json files. So, if you will want to compare what it is different with the template saved, you can save the new template:
cd aws-cdk-remove-identifiers/
npm test -- tests/removeIdentifiers.test.ts > tests/templateWithoutIdentifiers.json.2
This approach is comfortable for running your program for comparison, like Meld, diff or fc:
cd aws-cdk-remove-identifiers/
diff tests/templateWithoutIdentifiers.json tests/templateWithoutIdentifiers.json.2