Add chai plugin for the tool and add properties and methods.
Examples:
// stack.test.ts
import * as cdk from 'aws-cdk-lib';
import * as MyStack from '../lib/mystack.ts';
import { chaiPlugin } from 'aws-cdk-assert';
import { use } from 'chai';
use(chaiPlugin);
describe('MyStack', () => {
let stack: MyStack.Mystack;
beforeAll(() => {
const app = new cdk.App();
stack = new MyStack.MyStack(app, 'MyStack', {
// props
});
});
test('should have S3 Bucket', () => {
expect(stack).to.have.s3Bucket({ bucketName: 'MyBucket' });
});
});
Options:
- Single method per resource type with properties object for simple properties:
expect(stack).to.have.s3Bucket({ bucketName: 'MyBucket' });
- Resource properties and methods per each simple property (same as the resource methods):
expect(stack).with.s3Bucket.withBucketName('MyBucket').exists;
Add chai plugin for the tool and add properties and methods.
Examples:
Options:
expect(stack).to.have.s3Bucket({ bucketName: 'MyBucket' });expect(stack).with.s3Bucket.withBucketName('MyBucket').exists;