New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@fleetplannerscollective/cest

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fleetplannerscollective/cest

Small and light test runner for typescript

latest
Source
npmnpm
Version
1.0.8
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

Cest

Cest is a small and light test runner for typescript.

I got frustrated with how slow Jest was at running tests, so I made this. It's simple and works.

Installation

npm install @fleetplannerscollective/cest

Write some tests

import cest from '@fleetplannerscollective/cest' // import cest
import { strict as assert } from 'assert' // use the default assertion library from node

const test = cest('my test suite') // Create a suite

test(                // define a test
    'passing test',  // give the test a name
    () => {          // create a funtion to run the test
        assert(true) // if the function doesn't throw an error, the test passes
    }
)

test(
    'failing test', 
    () => {
        assert(false) // if the function throws an error, the test fails
    }
)

test(
    'should throw', 
    () => {
        const t = () => {throw new Error()}
        assert.throws(t, Error) // For tests which should throw an error, use assert.throws, provided by node.js
    }
)

test(
    'async test', 
    async () => { // Cest handles async tests fine
        await new Promise((resolve) => {resolve(true)})
    }
)

test.run() // run all the tests

Run all tests

Use the cli tool:

cest [path/to/ts/dir]

Cest will identify all .test.ts files in the path, find .tsconfig locate the compiled .js files and run them. Cest will also identify all .test.js files in the path and run them.

Run a single test suite without CLI

You can run a sinlge test suite by directly calling the .js file node mytest.js

Run tests programatically

import cest from '@fleetplannerscollective/cest'

const result = cest.runner('path to tests')
if (result) {
    // tests passed
} else {
    // tests failed
}

Development

  • Clone the repo.
  • Install dev dependencies npm install.
  • Run npm run build
  • Run npm run test

To remove the dist folder for a completely fresh build npm run clean.

To incrementally rebuild whilst working npm run watch.

Keywords

test

FAQs

Package last updated on 19 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts