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.3
Version published
Weekly downloads
52
108%
Maintainers
1
Weekly downloads
 
Created
Source

assertior

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

Development in progress
Сurrent usage and avaliable API (toEqual, toDeepEqual), 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});
  });

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

  it('toDeepEqual positive', function() {
    const val = {a: 2, b: 3, c: [1, 2, 3]};
    expect(val).toDeepEqual({a: 2, c: [1, 2, 3], b: 3});
  });
});
Сurrent usage and avaliable API (toEqual, toDeepEqual), 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('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});
  });

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

  it('toDeepEqual positive', function() {
    const val = {a: 2, b: 3, c: [1, 2, 3]};
    expect(val).toDeepEqual({a: 2, c: [1, 2, 3], b: 3});
  });
});

Keywords

soft assertion

FAQs

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