npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@rophy123/helmtest

v2.1.5

Published

Write unit tests against your helm charts using JavaScript.

Downloads

3

Readme

helmtest

A npm module which enables writing unit tests with nodejs / Jest.

Heavily inspired by Stono/helmtest.

Why not just use Stono/helmtest?

I originally wanted to update Stono/helmtest to fit my needs, but after attempting to customize it, I figured it's actually easier to rewrite one.

Differences with Stono/helmtest:

  • Single js file for the core logic (lib/helmtest.js)
  • Supports kubeconform instead of kubeval
  • No Grunt and TypeScript
  • Can be used as a npm library without assuming test framework and passing objects around global scope.
  • Can also run independently as CLI. In this case jest is bundled instead of mocha/chai.

Getting Started

Running helmtest as npm module

Install helmtest:

npm install @rophy123/helmtest

To use helmtest in your code:

const helmtest = require('@rophy123/helmtest');

// Run `helm template` under working directory
helmtest.renderTemplate()
.then(results => {
  // results are JS objects converted from result YAML.
  // '[{"apiVesrion":"v1","kind":"ServiceAccount","metadata":...
  console.log(JSON.stringify(results));
});

The results object can be used to verify details. For example, in jest:

const helmtest = require('@rophy123/helmtest');

test('exmapleChart should render 4 resources', async () => {
  const result = await helmtest.renderTemplate();
  expect(result.length).toBe(4);
});

See API Spec for the options of helmtest.renderTemplate().

Running helmtest as CLI

Install jest along with helmtest globally:

npm install -g @rophy123/helmtest jest

...and then you can write unit tests under tests/ dir of your chart project without the need for package.json

A docker image rophy/helmtest is avilable which includes everything to run up unit tests.

See example as an example helm chart project on how to use docker image and write unit tests.

API Spec

helmtest currently only expose one method: helmtest.renderTemplate(options).

options is a object with option names, descriptions and defaults as below:

| Option | Description | Default | | -------------------- | ----------------------------------------------------------------------------------- | --------------------------------------------------- | | chartDir | Path to chart, the CHART arg in helm CLI: helm template [NAME] [CHART] [flags]. | '.' | | releaseName | Release name, the NAME arg in helm CLI: helm template [NAME] [CHART] [flags]. | 'release-name' | | values | Map of chart values to set. | {} | | valuesFiles | Paths to additional values.yaml. | [] | | templateFiles | Render only listed template files, e.g. ['templates/hpa.yaml'] | [] | | extraHelmArgs | Extra args to pass to helm CLI, e.g. --timeout=5s | [] | | helmBinary | Path to helm binary. | process.env.HELM_BINARY \|\| 'helm' | | loadYaml | if false, will return rendered template as raw string instead of js object. | true | | kubeconformEnabled | if true, will pass rendered template to kubeconform CLI to validate schema. | process.env.KUBECONFORM_ENABLED \|\| false | | kubeconformBinary | Path to kubeconform binary. | process.env.KUBECONFORM_BINARY \|\| 'kubeconform' | | kubeconformArgs | Args to pass to kubeconform CLI. Will append process.env.KUBECONFORM_EXTRA_ARGS. | ['-strict','-summary'] |