Skip to content
This repository was archived by the owner on May 19, 2026. It is now read-only.

duniul/cdktf-vitest

Repository files navigation

⚠️ Deprecated

With CDKTF being officially deprecated, so is this lib!

The original readme is left below.

cdktf-vitest

npm

🧪 Terraform CDK's assertions for Vitest.

Installation

npm install cdktf-vitest --save-dev

cdktf-vitest has peer dependencies on both cdktf and vitest, so remember to install those too!

Usage

  1. Import and call setupCdktfVitest in a a setup file:

    // vitest.setup.ts or similar
    import { setupCdktfVitest } from 'cdktf-vitest';
    
    setupCdktfVitest();
  2. Add cdktf-vitest to types in your tsconfig.json:

    // tsconfig.json
    {
      "compilerOptions": {
        "types": ["cdktf-vitest"]
      }
    }

    ❗️ If you don't set types, you'll need to add import 'cdktf-vitest' to the top of each test file.

  3. Done! 🎉 The assertions should now be available from theexpect function, 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.

About

🧪 Terraform CDK matchers for Vitest

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors