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

codeceptjs-assert

v0.0.5

Published

CodeceptJS helper for assert library

Downloads

54,071

Readme

codeceptjs-assert

codeceptjs-assert is CodeceptJS helper which wraps assert library to complete assertion tests with CodeceptJS logging. This wrapper allow us to print asserts as steps in output. Also we can expand this lib with different methods and other assertion libraries.

NPM package: https://www.npmjs.com/package/codeceptjs-assert

Configuration

This helper should be added in codecept.json/codecept.conf.js

Example:

{
   "helpers": {
     "AssertWrapper" : {
       "require": "codeceptjs-assert"
     }
   }
}

assert

Tests shallow, coercive equality between the actual and expected parameters using the Abstract Equality Comparison ( == ).

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_equal_actual_expected_message

I.assert('true', true);

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertDeepEqual

Tests for deep equality between the actual and expected parameters. Primitive values are compared with the Abstract Equality Comparison ( == ).

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_deepequal_actual_expected_message

I.assertDeepEqual({ a: { b: 1 } }, { a: { b: 2 } });

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertDeepStrictEqual

Generally identical to assert.deepEqual() with a few exceptions:

  • Primitive values are compared using the Strict Equality Comparison ( === ). Set values and Map keys are compared using the SameValueZero comparison. (Which means they are free of the caveats).
  • [[Prototype]] of objects are compared using the Strict Equality Comparison too.
  • Type tags of objects should be the same.
  • Object wrappers are compared both as objects and unwrapped values.

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_deepstrictequal_actual_expected_message

I.assertDeepStrictEqual({ a: 1 }, { a: '1' });

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertEqual

Alias to assert method

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_equal_actual_expected_message

I.assertEqual('true', true);

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertFail

Throws an AssertionError. The error message is set as the values of actual and expected separated by the provided operator

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_fail_actual_expected_message_operator_stackstartfunction

I.assertFail('true', true);

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display
  • operator - (optional) default: !=

assertOk

Tests if value is truthy.

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_ok_value_message

I.assertOk(1 == '1', 'not equal');

Parameters

  • value - any value
  • message - (optional) error message to display

assertNotEqual

Check that actual and expected are not equal

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_notequal_actual_expected_message

I.assertNotEqual('true', 'foo');

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertNotDeepStrictEqual

Tests for any deep inequality.

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_notdeepequal_actual_expected_message

I.assertNotDeepStrictEqual({ a: { b: 1 } }, { a: { b: 2 } });

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertNotDeepEqual

Tests for any deep inequality.

https://nodejs.org/docs/latest-v8.x/api/assert.html#assert_assert_notdeepequal_actual_expected_message

I.assertNotDeepEqual({ a: { b: 1 } }, { a: { b: 2 } });

Parameters

  • actual - actual result
  • expected - expected result
  • message - (optional) error message to display

assertStatusCode

Compare expected and actual status code.

I.assertStatusCode(200, 400);

Parameters

  • actual - actual result
  • expected - expected result

assertBodyIsNotEmpty

Expect that body is not empty.

I.assertBodyIsNotEmpty({foo: 'bar'});

Parameters

  • actual - actual result
  • message - (optional) error message to display

assertKeyInObjectExists

Check that list of keys are in object.

I.assertKeyInObjectExists('foo.bar.three', {foo: 'bar', bar: 'foo'});

Parameters

  • keys - list of keys split by `.
  • obj - tested object

assertKeyInObjectNotExists

Check that list of keys are not in object

I.assertKeyInObjectNotExists('foo.bar.three', {foo: 'bar', bar: 'foo'});

Parameters

  • keys - list of keys split by `.
  • obj - tested object

assertEach

Check that each element in array match predicate

I.assertEach(['foo', 3], (el) => typeof el == 'string');

Parameters

  • items - tested array
  • predicate - predicate function. should return true for each element
  • message - error message to display

assertExists

Check that array has at least one element that match predicate

I.assertExists(['foo', 3], (el) => typeof el == 'string');

Parameters

  • items - tested array
  • predicate - predicate function. should return true for each element
  • message - error message to display

assertStringIncludes

Check that string contains substring

I.assertStringIncludes('mystring'. 'str');

Parameters

  • actual - tested string
  • substring - expected substring