Better support for testing from engines

Adam Eisenreich akxe at
Tue Jul 2 07:44:52 UTC 2019

Assuming code like this:
import { compoteGraph } from './compute-graph';

export function doTheMath() {
  //  Elaborate work to gather parameters for `computeGraph`.

  const param1 = 1;

  const param2 = 'a';

  const param3 = 'A';

  return computeGraph(param1, param2, param3);



And it's test


import { doTheMath } from './do-the-math';

describe(..., () => {

  it(..., () => {

    expect(doTheMath()).toEqual([1, 'a', 'A']);



If you would like to mock the `computeGraph` to return fixed value, for 
example array of parameters, you to my knowledge don't have other way, than 
using Jest, that does it by utilizing webpack (and possibli other) in the 

Or am I wrong? Is there a way to mock imported (`computeGraph`) function 
from within the test?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list