Skip to content

Invoking custom helper I.methodName(null) method resulted into crash due to a logic error in lib/step.js #2493

@sjana-aj

Description

@sjana-aj

What are you trying to achieve?

I am trying to invoke a custom helper I.methodName(null) method with null argument to assert null value present in one of the json field.

What do you get instead?

Provide console output if related. Use --verbose mode for more details.

     Cannot read property 'toString' of null
  ypeError: Cannot read property 'toString' of null
      at G:\CodeceptJS-Test\node_modules\codeceptjs\lib\step.js:115:22
      at Array.map (<anonymous>)
      at Step.humanizeArgs (node_modules\codeceptjs\lib\step.js:98:22)
      at Step.toString (node_modules\codeceptjs\lib\step.js:133:67)
      at Object.emit (node_modules\codeceptjs\lib\event.js:112:24)

Provide test source code if related

My Helper class looks like below:

// eslint-disable-next-line no-undef
const Helper     = codecept_helper;
const { expect } = require( 'chai' );

class ChaiExtraHelper extends Helper{

  assertNull( data ){

    return expect( data ).to.be.null;
  
  }

}

module.exports = ChaiExtraHelper;

My test looks like below:

I.assertNull(null);

Details

  • CodeceptJS version: 2.6.6
  • NodeJS Version: 12.13.0
  • Operating System: Windows 10
  • puppeteer || webdriverio || protractor || testcafe version (if related)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions