TypeError: (0 , _helper.addValue) is not a function Jest Error










0















Jest is giving an error of function undefined even when the function is defined in the specified file. I'm testing a function defined in cards.js but jest is also executing my reducer file when I run my test using 'npm
test' and it is giving an error in reducer file that fun is not defined but that function is defined in helper.js and also working perfectly when I run my app. It only gives an error in npm test console.



Error: ● Test suite failed to run
TypeError: (0 , _helper.addValue) is not a function



helper.js



export const addValue = (a, b) => a+ b


filter.reducer.js



import addValue from '../helper';
const result = addValue(5,4);
.
.
.
.


cards.js



import pipe, prop from 'ramda'
exprot const transformCardData = (response) =>
if(isEmpty(response))
return

return pip(
prop('values)
)



`
cards.test.js



describe('testing transformCardData function ', ()=>
it('testing empty response',()=>
expect(transformCardData()).toBe()




package.json jest config



"scripts": 
"analyze": "source-map-explorer build/static/js/main.*",
"start": "node scripts/start.js",
"build": "NODE_ENV='production' GENERATE_SOURCEMAP=false node scripts/build.js",
"test": "node scripts/test.js"
,
"jest":
"collectCoverageFrom": [
"src/**/*.js,jsx,mjs"
],
"setupFiles": [
"<rootDir>/config/polyfills.js"
],
"testMatch": [
"<rootDir>/src/**/__tests__/**/*.js,jsx,mjs",
"<rootDir>/src/**/?(*.)(spec,
"devDependencies":
"babel-jest": "20.0.3",
"jest": "^23.6.0",
"jest-cli": "^23.6.0",
.
.
.



test.js



'use strict';

// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'test';
process.env.NODE_ENV = 'test';
process.env.PUBLIC_URL = '';

// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err =>
throw err;
);

// Ensure environment variables are read.
require('../config/env');

const jest = require('jest');
const argv = process.argv.slice(2);

// Watch unless on CI or in coverage mode
if (!process.env.CI && argv.indexOf('--coverage') < 0)
argv.push('--watch');



jest.run(argv);









share|improve this question




























    0















    Jest is giving an error of function undefined even when the function is defined in the specified file. I'm testing a function defined in cards.js but jest is also executing my reducer file when I run my test using 'npm
    test' and it is giving an error in reducer file that fun is not defined but that function is defined in helper.js and also working perfectly when I run my app. It only gives an error in npm test console.



    Error: ● Test suite failed to run
    TypeError: (0 , _helper.addValue) is not a function



    helper.js



    export const addValue = (a, b) => a+ b


    filter.reducer.js



    import addValue from '../helper';
    const result = addValue(5,4);
    .
    .
    .
    .


    cards.js



    import pipe, prop from 'ramda'
    exprot const transformCardData = (response) =>
    if(isEmpty(response))
    return

    return pip(
    prop('values)
    )



    `
    cards.test.js



    describe('testing transformCardData function ', ()=>
    it('testing empty response',()=>
    expect(transformCardData()).toBe()




    package.json jest config



    "scripts": 
    "analyze": "source-map-explorer build/static/js/main.*",
    "start": "node scripts/start.js",
    "build": "NODE_ENV='production' GENERATE_SOURCEMAP=false node scripts/build.js",
    "test": "node scripts/test.js"
    ,
    "jest":
    "collectCoverageFrom": [
    "src/**/*.js,jsx,mjs"
    ],
    "setupFiles": [
    "<rootDir>/config/polyfills.js"
    ],
    "testMatch": [
    "<rootDir>/src/**/__tests__/**/*.js,jsx,mjs",
    "<rootDir>/src/**/?(*.)(spec,
    "devDependencies":
    "babel-jest": "20.0.3",
    "jest": "^23.6.0",
    "jest-cli": "^23.6.0",
    .
    .
    .



    test.js



    'use strict';

    // Do this as the first thing so that any code reading it knows the right env.
    process.env.BABEL_ENV = 'test';
    process.env.NODE_ENV = 'test';
    process.env.PUBLIC_URL = '';

    // Makes the script crash on unhandled rejections instead of silently
    // ignoring them. In the future, promise rejections that are not handled will
    // terminate the Node.js process with a non-zero exit code.
    process.on('unhandledRejection', err =>
    throw err;
    );

    // Ensure environment variables are read.
    require('../config/env');

    const jest = require('jest');
    const argv = process.argv.slice(2);

    // Watch unless on CI or in coverage mode
    if (!process.env.CI && argv.indexOf('--coverage') < 0)
    argv.push('--watch');



    jest.run(argv);









    share|improve this question


























      0












      0








      0








      Jest is giving an error of function undefined even when the function is defined in the specified file. I'm testing a function defined in cards.js but jest is also executing my reducer file when I run my test using 'npm
      test' and it is giving an error in reducer file that fun is not defined but that function is defined in helper.js and also working perfectly when I run my app. It only gives an error in npm test console.



      Error: ● Test suite failed to run
      TypeError: (0 , _helper.addValue) is not a function



      helper.js



      export const addValue = (a, b) => a+ b


      filter.reducer.js



      import addValue from '../helper';
      const result = addValue(5,4);
      .
      .
      .
      .


      cards.js



      import pipe, prop from 'ramda'
      exprot const transformCardData = (response) =>
      if(isEmpty(response))
      return

      return pip(
      prop('values)
      )



      `
      cards.test.js



      describe('testing transformCardData function ', ()=>
      it('testing empty response',()=>
      expect(transformCardData()).toBe()




      package.json jest config



      "scripts": 
      "analyze": "source-map-explorer build/static/js/main.*",
      "start": "node scripts/start.js",
      "build": "NODE_ENV='production' GENERATE_SOURCEMAP=false node scripts/build.js",
      "test": "node scripts/test.js"
      ,
      "jest":
      "collectCoverageFrom": [
      "src/**/*.js,jsx,mjs"
      ],
      "setupFiles": [
      "<rootDir>/config/polyfills.js"
      ],
      "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.js,jsx,mjs",
      "<rootDir>/src/**/?(*.)(spec,
      "devDependencies":
      "babel-jest": "20.0.3",
      "jest": "^23.6.0",
      "jest-cli": "^23.6.0",
      .
      .
      .



      test.js



      'use strict';

      // Do this as the first thing so that any code reading it knows the right env.
      process.env.BABEL_ENV = 'test';
      process.env.NODE_ENV = 'test';
      process.env.PUBLIC_URL = '';

      // Makes the script crash on unhandled rejections instead of silently
      // ignoring them. In the future, promise rejections that are not handled will
      // terminate the Node.js process with a non-zero exit code.
      process.on('unhandledRejection', err =>
      throw err;
      );

      // Ensure environment variables are read.
      require('../config/env');

      const jest = require('jest');
      const argv = process.argv.slice(2);

      // Watch unless on CI or in coverage mode
      if (!process.env.CI && argv.indexOf('--coverage') < 0)
      argv.push('--watch');



      jest.run(argv);









      share|improve this question
















      Jest is giving an error of function undefined even when the function is defined in the specified file. I'm testing a function defined in cards.js but jest is also executing my reducer file when I run my test using 'npm
      test' and it is giving an error in reducer file that fun is not defined but that function is defined in helper.js and also working perfectly when I run my app. It only gives an error in npm test console.



      Error: ● Test suite failed to run
      TypeError: (0 , _helper.addValue) is not a function



      helper.js



      export const addValue = (a, b) => a+ b


      filter.reducer.js



      import addValue from '../helper';
      const result = addValue(5,4);
      .
      .
      .
      .


      cards.js



      import pipe, prop from 'ramda'
      exprot const transformCardData = (response) =>
      if(isEmpty(response))
      return

      return pip(
      prop('values)
      )



      `
      cards.test.js



      describe('testing transformCardData function ', ()=>
      it('testing empty response',()=>
      expect(transformCardData()).toBe()




      package.json jest config



      "scripts": 
      "analyze": "source-map-explorer build/static/js/main.*",
      "start": "node scripts/start.js",
      "build": "NODE_ENV='production' GENERATE_SOURCEMAP=false node scripts/build.js",
      "test": "node scripts/test.js"
      ,
      "jest":
      "collectCoverageFrom": [
      "src/**/*.js,jsx,mjs"
      ],
      "setupFiles": [
      "<rootDir>/config/polyfills.js"
      ],
      "testMatch": [
      "<rootDir>/src/**/__tests__/**/*.js,jsx,mjs",
      "<rootDir>/src/**/?(*.)(spec,
      "devDependencies":
      "babel-jest": "20.0.3",
      "jest": "^23.6.0",
      "jest-cli": "^23.6.0",
      .
      .
      .



      test.js



      'use strict';

      // Do this as the first thing so that any code reading it knows the right env.
      process.env.BABEL_ENV = 'test';
      process.env.NODE_ENV = 'test';
      process.env.PUBLIC_URL = '';

      // Makes the script crash on unhandled rejections instead of silently
      // ignoring them. In the future, promise rejections that are not handled will
      // terminate the Node.js process with a non-zero exit code.
      process.on('unhandledRejection', err =>
      throw err;
      );

      // Ensure environment variables are read.
      require('../config/env');

      const jest = require('jest');
      const argv = process.argv.slice(2);

      // Watch unless on CI or in coverage mode
      if (!process.env.CI && argv.indexOf('--coverage') < 0)
      argv.push('--watch');



      jest.run(argv);






      javascript reactjs npm jestjs babel-jest






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 13 '18 at 10:12









      skyboyer

      3,44111128




      3,44111128










      asked Nov 13 '18 at 6:11









      Nouman AltafNouman Altaf

      13




      13






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274842%2ftypeerror-0-helper-addvalue-is-not-a-function-jest-error%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53274842%2ftypeerror-0-helper-addvalue-is-not-a-function-jest-error%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          這個網誌中的熱門文章

          How to read a connectionString WITH PROVIDER in .NET Core?

          In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

          Museum of Modern and Contemporary Art of Trento and Rovereto