Skip to content

Latest commit

 

History

History
 
 

testing-unit-ts

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Unit Testing Pulumi programs in TypeScript

An example of writing mock-based unit tests with both infrastructure definition and tests written in TypeScript. The example uses the Mocha test framework to define and run the tests.

Prerequisites

  1. Ensure you have the latest Node.js and NPM.
  2. Install the Mocha test framework.

Running the tests

  1. Restore NPM dependencies:

    $ npm install
    
  2. Run the tests:

    $ PULUMI_TEST_MODE=true  \
        PULUMI_NODEJS_STACK="my-ws" \
        PULUMI_NODEJS_PROJECT="dev" \
        PULUMI_CONFIG='{ "aws:region": "us-west-2" }'  \
        mocha -r ts-node/register ec2tests.ts
    
    Infrastructure
      #server
        ✓ must have a name tag
        ✓ must not use userData (use an AMI instead)
      #group
        ✓ must not open port 22 (SSH) to the Internet
    
    3 passing (420ms)