cdktf-vitest
v0.1.2
Published
Terraform CDK matchers for Vitest
Downloads
2,196
Maintainers
Readme
cdktf-vitest
🧪 Terraform CDK's assertions for Vitest.
- Vitest assertions identical to
cdktf's official Jest assertions. - Works with both global and imported
expect.
Installation
npm install cdktf-vitest --save-devcdktf-vitest has peer dependencies on both cdktf and vitest, so remember to install those too!
Usage
Import and call
setupCdktfVitestin a a setup file:// vitest.setup.ts or similar import { setupCdktfVitest } from 'cdktf-vitest'; setupCdktfVitest();Add
cdktf-vitesttotypesin yourtsconfig.json:// tsconfig.json { "compilerOptions": { "types": ["cdktf-vitest"] } }❗️ If you don't set
types, you'll need to addimport 'cdktf-vitest'to the top of each test file.Done! 🎉 The assertions should now be available from the
expectfunction, like:import { expect } from 'vitest'; expect(stack).toHaveResouce(resource);The assertions work exactly like Terraform CDK's official assertions for Jest. For information on how to use them, see their documentation on unit testing with Jest.
