You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

assertior

Package Overview
Dependencies
Maintainers
1
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

assertior

Assertion library with soft assertions

npmnpm
Version
0.0.6
Version published
Weekly downloads
41
51.85%
Maintainers
1
Weekly downloads
 
Created
Source

assertior

🛠 Development in progress

This library is a wrapper around nodejs "assert" module

The main porpuse is build new assertion library with soft assertions based on "assert" module

allure/any other reporter ready

mocha example
const {expect} = require('assertior');

describe('Suite', function() {
  it('soft toEqual positive', function() {
    const val = 2;
    expect.soft(val).toEqual(2);
  });

  it('soft toDeepEqual positive', function() {
    const val = {a: 2, b: 3, c: [1, 2, 3]};
    expect.soft(val).toDeepEqual({a: 2, c: [1, 2, 3], b: 3});
  });
});
mocha example with allure
// Allure step
function allureStep(stepAssertionName: string, error, expected, current) {
  const step = allure.startStep(stepAssertionName);
  allure.attachment('Expected value', JSON.stringify(expected, null, 2), 'application/json');
  allure.attachment('Current value', JSON.stringify(current, null, 2), 'application/json');
  if (error) {
    allure.attachment('Error', JSON.stringify(error, null, 2), 'application/json');
  }
  step.step.stepResult.status = error ? 'broken' : 'passed';
  step.endStep();
}

const {expect, initStepDeclarator} = require('assertior');
initStepDeclarator(allureStep);


describe('Suite', function() {
  it('soft toEqual positive', function() {
    const val = 2;
    expect.soft(val).toEqual(2);
  });

  it('toDeepEqual positive', function () {
    const val = 2;
    expect(val).toDeepEqual(2);
  });
});
  • expect.soft
  • expect

expect

toDeepEqual

  const {expect} = require('assertior');
  expect([{foo: 'bar'}]).toDeepEqual([{foo: 'bar'}]);

toEqual

  const {expect} = require('assertior');
  expect('bar').toEqual('bar');

toBeEmptyArray

  const {expect} = require('assertior');
  expect([]).toBeEmptyArray();

toBeNotEmptyArray

  const {expect} = require('assertior');
  expect([1,2,3]).toBeNotEmptyArray();

objectIncludesKeys

  const {expect} = require('assertior');
  expect({foo: 'bar'}).objectIncludesKeys(['foo']);

hasType

  const {expect} = require('assertior');
  expect({foo: 'bar'}).hasType('object');
  expect([]).hasType('array');
  expect(null).hasType('null');

expect.soft

toEqual

  const {expect} = require('assertior');
  expect.soft('bar').toEqual('bar');

toBeEmptyArray

  const {expect} = require('assertior');
  expect.soft([]).toBeEmptyArray();

toBeNotEmptyArray

  const {expect} = require('assertior');
  expect.soft([1,2,3]).toBeNotEmptyArray();

objectIncludesKeys

  const {expect} = require('assertior');
  expect.soft({foo: 'bar'}).objectIncludesKeys(['foo']);

hasType

  const {expect} = require('assertior');
  expect.soft({foo: 'bar'}).hasType('object');
  expect.soft([]).hasType('array');
  expect.soft(null).hasType('null');

Keywords

soft assertion

FAQs

Package last updated on 18 Aug 2020

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