Socket
Book a DemoInstallSign in
Socket

cases-of-test

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

cases-of-test

Run test locally with only/skip flag but with the condition that it can detect there are tests flagged with only and it will fail on CI/CD environment

unpublished
latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

cases-of-test

It groups the test cases into a collection of tests so that you can do the following

testCases({
    tests: [
        [testAlphabet],
        [testArray],
        [testCapitalizeUncapitalize],
        [testCreateGranulaString],
        [testIsEqual],
        [testInRangeOfMinMax],
        [testNumber, 'only'],
        [testReverse, 'only'],
        [testWhitespace],
    ],
});

Which will then execute testNumber and testReverse only by your testing framework

It will also abort the tests when it detect there are tests flagged with only and thus fail the CI/CD

Why I made this

I used to add only to describe or/and test/it a lot in my codebase back in the days like so

describe.only('...', () => {
    it.only('...', () => {
        // tests...
    });
});

The problem is that I won't know whether all of the tests are executed in CI/CD environment, since it doesn't warn that there are tests config with only. In the end, I have to open the log to find out

Other times I write code like this,

import test1 from 'test1';
import test2 from 'test2';

test1();
test2();

And I will comment out irrelevant test when I wanna test new changes

In the end I forgot to uncomment the commented tests in CI/CD environment

Output

When there are test flagged with only, the following will happen in CI/CD environment

SetupOutput
CodeOutput

Images from the log of Github Actions of denoify repository

How to use

  • Install this package
  • Have a testing framework ready, i.e. jest, vitest
  • Create a file to wrap your tests
  • Set the entry point of the testing framework to that file you created
  • Run the test command

Disclaimer

  • This is not a testing framework

Keywords

vitest

FAQs

Package last updated on 28 Oct 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