How to use the browserify.mockReturnValue function in browserify

To help you get started, we’ve selected a few browserify examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github johnelm / node-jxa / node-jxa.spec.js View on Github external
test( 'returns non-zero exit code when child process errors', () => {

  let b = {
    add: jest.fn(),
    bundle: jest.fn( cb => { cb( null, SRC ) } )
  }
  browserify.mockReturnValue( b );

  let write = jest.fn();
  let end = jest.fn();
  let on = jest.fn();
  on.mockReturnValueOnce( 1 );
  on.mockReturnValueOnce( Error( 'an error occured while spawning the process') );


  cp.spawn = jest.fn() ;
  cp.spawn.mockReturnValue( {
    stdin: { write, end },
    on
  })

  nodeJxa( './example.js', { debug: true } );