0.1.2 โข Published 2 years ago
cdktf-vitest v0.1.2
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.