How to configure Jest to work with Expo SDK 322019 Community Moderator ElectionReact Native Expo App: How to get it to run Jest testsBabel jest isn't working with loaded css moduleHow to solve the warning message of React NativeShare codebase using common Sdk module in create react app Reactjs applicationTest runner (jest) failing to import expo modulesJest-expo test doesn't runJest testing ( using babel ) invalid token importThe Expo SDK requires Expo to runreact native bundling failed: Error: Requires Babel “^7.0.0-0”, but was loaded with “6.26.3”ReactJS: unexpected token '<'React native expo app with snapshot jest tests configuration

Why the color red for the Republican Party

Is Gradient Descent central to every optimizer?

Can't find the Shader/UVs tab

Why would one plane in this picture not have gear down yet?

Make a transparent 448*448 image

How did Alan Turing break the enigma code using the hint given by the lady in the bar?

Best approach to update all entries in a list that is paginated?

What does a stand alone "T" index value do?

Making a sword in the stone, in a medieval world without magic

"One can do his homework in the library"

How to create a hard link to an inode (ext4)?

Should I take out a loan for a friend to invest on my behalf?

PTIJ: Why can't I eat anything?

Built-In Shelves/Bookcases - IKEA vs Built

Is it true that real estate prices mainly go up?

How do I express some one as a black person?

Is there any way to damage Intellect Devourer(s) when already within a creature's skull?

Why is there a voltage between the mains ground and my radiator?

Placing subfig vertically

Fourth person (in Slavey language)

Solving "Resistance between two nodes on a grid" problem in Mathematica

Reverse string, can I make it faster?

Why does Deadpool say "You're welcome, Canada," after shooting Ryan Reynolds in the end credits?

My story is written in English, but is set in my home country. What language should I use for the dialogue?



How to configure Jest to work with Expo SDK 32



2019 Community Moderator ElectionReact Native Expo App: How to get it to run Jest testsBabel jest isn't working with loaded css moduleHow to solve the warning message of React NativeShare codebase using common Sdk module in create react app Reactjs applicationTest runner (jest) failing to import expo modulesJest-expo test doesn't runJest testing ( using babel ) invalid token importThe Expo SDK requires Expo to runreact native bundling failed: Error: Requires Babel “^7.0.0-0”, but was loaded with “6.26.3”ReactJS: unexpected token '<'React native expo app with snapshot jest tests configuration










2















I have an Expo app and was using SDK 28. My team decided we should update to the latest version, that meant updating React Native (Since the latest SDK uses RN 0.57) and Babel.



When we updated our dependencies, and fixed our config files, Jest started to give us this error:



TypeError: Cannot read property 'fetch' of undefined

at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:6:12
at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:486:3)
at Object.<anonymous> (node_modules/jest-expo/src/setup.js:125:16)


After a few days debugging I found out this is related to babel-jest's pre-processor not working correctly, even though I followed their installation docs.



I dug around some more and found out that there's a workaround in this GitHub Issue thread.



Implementing the workaround, plus adding babel-hoist to my babel.config.js, made so that the tests started running.



However Jest's behavior is all wonky and the coverage data is not correct (it counts some lines as uncovered, even though we do have tests for them).



I want to know how to configure Jest properly for compatibility with Expo SDK 32.



These are the relevant config files (which are set to use the workaround mentioned previously).



package.json*



"dependencies": 
"@babel/preset-env": "^7.3.1",
"@expo/vector-icons": "6.3.1",
"expo": "^32.0.0",
"prop-types": "15.6.2",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"sentry-expo": "~1.9.0"
...
,
"devDependencies":
"@babel/core": "^7.2.2",
"babel-eslint": "9.0.0",
"babel-plugin-jest-hoist": "^24.0.0",
"babel-preset-expo": "^5.0.0",
"enzyme": "3.8.0",
"enzyme-adapter-react-16": "^1.8.0",
"jest-expo": "^32.0.0",
"metro-react-native-babel-preset": "^0.51.1",
"react-dom": "^16.5.1",
...
,
"jest":
"preset": "jest-expo",
"transform":
"^.+\.js$": "<rootDir>/jest.preprocessor.js"
,
"setupFiles": [
"<rootDir>/src/jest.setup.js"
],
...



* Some dependecies were omitted.



babel.config.js



module.exports = 
presets: [
'babel-preset-expo',
'module:metro-react-native-babel-preset',
'module:react-native-dotenv',
[
'@babel/preset-env',

targets:
node: 'current',
,
,
],
],
sourceMaps: true,
plugins: [
'jest-hoist',
'@babel/transform-react-jsx-source',
],
;









share|improve this question




























    2















    I have an Expo app and was using SDK 28. My team decided we should update to the latest version, that meant updating React Native (Since the latest SDK uses RN 0.57) and Babel.



    When we updated our dependencies, and fixed our config files, Jest started to give us this error:



    TypeError: Cannot read property 'fetch' of undefined

    at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:6:12
    at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:486:3)
    at Object.<anonymous> (node_modules/jest-expo/src/setup.js:125:16)


    After a few days debugging I found out this is related to babel-jest's pre-processor not working correctly, even though I followed their installation docs.



    I dug around some more and found out that there's a workaround in this GitHub Issue thread.



    Implementing the workaround, plus adding babel-hoist to my babel.config.js, made so that the tests started running.



    However Jest's behavior is all wonky and the coverage data is not correct (it counts some lines as uncovered, even though we do have tests for them).



    I want to know how to configure Jest properly for compatibility with Expo SDK 32.



    These are the relevant config files (which are set to use the workaround mentioned previously).



    package.json*



    "dependencies": 
    "@babel/preset-env": "^7.3.1",
    "@expo/vector-icons": "6.3.1",
    "expo": "^32.0.0",
    "prop-types": "15.6.2",
    "react": "16.5.0",
    "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
    "sentry-expo": "~1.9.0"
    ...
    ,
    "devDependencies":
    "@babel/core": "^7.2.2",
    "babel-eslint": "9.0.0",
    "babel-plugin-jest-hoist": "^24.0.0",
    "babel-preset-expo": "^5.0.0",
    "enzyme": "3.8.0",
    "enzyme-adapter-react-16": "^1.8.0",
    "jest-expo": "^32.0.0",
    "metro-react-native-babel-preset": "^0.51.1",
    "react-dom": "^16.5.1",
    ...
    ,
    "jest":
    "preset": "jest-expo",
    "transform":
    "^.+\.js$": "<rootDir>/jest.preprocessor.js"
    ,
    "setupFiles": [
    "<rootDir>/src/jest.setup.js"
    ],
    ...



    * Some dependecies were omitted.



    babel.config.js



    module.exports = 
    presets: [
    'babel-preset-expo',
    'module:metro-react-native-babel-preset',
    'module:react-native-dotenv',
    [
    '@babel/preset-env',

    targets:
    node: 'current',
    ,
    ,
    ],
    ],
    sourceMaps: true,
    plugins: [
    'jest-hoist',
    '@babel/transform-react-jsx-source',
    ],
    ;









    share|improve this question


























      2












      2








      2








      I have an Expo app and was using SDK 28. My team decided we should update to the latest version, that meant updating React Native (Since the latest SDK uses RN 0.57) and Babel.



      When we updated our dependencies, and fixed our config files, Jest started to give us this error:



      TypeError: Cannot read property 'fetch' of undefined

      at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:6:12
      at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:486:3)
      at Object.<anonymous> (node_modules/jest-expo/src/setup.js:125:16)


      After a few days debugging I found out this is related to babel-jest's pre-processor not working correctly, even though I followed their installation docs.



      I dug around some more and found out that there's a workaround in this GitHub Issue thread.



      Implementing the workaround, plus adding babel-hoist to my babel.config.js, made so that the tests started running.



      However Jest's behavior is all wonky and the coverage data is not correct (it counts some lines as uncovered, even though we do have tests for them).



      I want to know how to configure Jest properly for compatibility with Expo SDK 32.



      These are the relevant config files (which are set to use the workaround mentioned previously).



      package.json*



      "dependencies": 
      "@babel/preset-env": "^7.3.1",
      "@expo/vector-icons": "6.3.1",
      "expo": "^32.0.0",
      "prop-types": "15.6.2",
      "react": "16.5.0",
      "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
      "sentry-expo": "~1.9.0"
      ...
      ,
      "devDependencies":
      "@babel/core": "^7.2.2",
      "babel-eslint": "9.0.0",
      "babel-plugin-jest-hoist": "^24.0.0",
      "babel-preset-expo": "^5.0.0",
      "enzyme": "3.8.0",
      "enzyme-adapter-react-16": "^1.8.0",
      "jest-expo": "^32.0.0",
      "metro-react-native-babel-preset": "^0.51.1",
      "react-dom": "^16.5.1",
      ...
      ,
      "jest":
      "preset": "jest-expo",
      "transform":
      "^.+\.js$": "<rootDir>/jest.preprocessor.js"
      ,
      "setupFiles": [
      "<rootDir>/src/jest.setup.js"
      ],
      ...



      * Some dependecies were omitted.



      babel.config.js



      module.exports = 
      presets: [
      'babel-preset-expo',
      'module:metro-react-native-babel-preset',
      'module:react-native-dotenv',
      [
      '@babel/preset-env',

      targets:
      node: 'current',
      ,
      ,
      ],
      ],
      sourceMaps: true,
      plugins: [
      'jest-hoist',
      '@babel/transform-react-jsx-source',
      ],
      ;









      share|improve this question
















      I have an Expo app and was using SDK 28. My team decided we should update to the latest version, that meant updating React Native (Since the latest SDK uses RN 0.57) and Babel.



      When we updated our dependencies, and fixed our config files, Jest started to give us this error:



      TypeError: Cannot read property 'fetch' of undefined

      at node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:6:12
      at Object.<anonymous> (node_modules/react-native/Libraries/vendor/core/whatwg-fetch.js:486:3)
      at Object.<anonymous> (node_modules/jest-expo/src/setup.js:125:16)


      After a few days debugging I found out this is related to babel-jest's pre-processor not working correctly, even though I followed their installation docs.



      I dug around some more and found out that there's a workaround in this GitHub Issue thread.



      Implementing the workaround, plus adding babel-hoist to my babel.config.js, made so that the tests started running.



      However Jest's behavior is all wonky and the coverage data is not correct (it counts some lines as uncovered, even though we do have tests for them).



      I want to know how to configure Jest properly for compatibility with Expo SDK 32.



      These are the relevant config files (which are set to use the workaround mentioned previously).



      package.json*



      "dependencies": 
      "@babel/preset-env": "^7.3.1",
      "@expo/vector-icons": "6.3.1",
      "expo": "^32.0.0",
      "prop-types": "15.6.2",
      "react": "16.5.0",
      "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
      "sentry-expo": "~1.9.0"
      ...
      ,
      "devDependencies":
      "@babel/core": "^7.2.2",
      "babel-eslint": "9.0.0",
      "babel-plugin-jest-hoist": "^24.0.0",
      "babel-preset-expo": "^5.0.0",
      "enzyme": "3.8.0",
      "enzyme-adapter-react-16": "^1.8.0",
      "jest-expo": "^32.0.0",
      "metro-react-native-babel-preset": "^0.51.1",
      "react-dom": "^16.5.1",
      ...
      ,
      "jest":
      "preset": "jest-expo",
      "transform":
      "^.+\.js$": "<rootDir>/jest.preprocessor.js"
      ,
      "setupFiles": [
      "<rootDir>/src/jest.setup.js"
      ],
      ...



      * Some dependecies were omitted.



      babel.config.js



      module.exports = 
      presets: [
      'babel-preset-expo',
      'module:metro-react-native-babel-preset',
      'module:react-native-dotenv',
      [
      '@babel/preset-env',

      targets:
      node: 'current',
      ,
      ,
      ],
      ],
      sourceMaps: true,
      plugins: [
      'jest-hoist',
      '@babel/transform-react-jsx-source',
      ],
      ;






      react-native jestjs babel expo babel-jest






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 5 at 9:15









      skyboyer

      4,02311230




      4,02311230










      asked Feb 4 at 20:42









      Bruno EduardoBruno Eduardo

      573213




      573213






















          2 Answers
          2






          active

          oldest

          votes


















          2














          This is what solved the problem for me:



          • First thing, install yarn. Follow this link for instructions.

          • Second, ensure your package.json looks something like this:

          "dependencies": 
          "@expo/vector-icons": "9.0.0",
          "expo": "^32.0.0",
          "prop-types": "15.6.2",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          ...
          ,

          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0",
          ...

          "scripts":
          "test": "jest",
          ...
          ,
          "jest":
          "preset": "jest-expo",
          "transform":
          "^.+\.js$": "babel-jest"
          ,



          • Third, ensure your babel.config.js is setup correctly. Here's the one from my project running Expo's SDK 32:

          module.exports = function (api) 
          api.cache(true);
          return
          presets: [
          'babel-preset-expo',
          'module:react-native-dotenv',
          ],
          sourceMaps: true,
          plugins: [
          '@babel/transform-react-jsx-source',
          ],
          ;
          ;


          • Lastly, use yarn to install your packages (yarn install) and to run your tests yarn test.





          share|improve this answer

























          • Worked for me but can you explain why it works with yarn but not with npm ?

            – baraber
            Mar 6 at 15:06











          • @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

            – Bruno Eduardo
            Mar 6 at 16:23











          • That could make sense since it look like some dependency issue.

            – baraber
            Mar 6 at 20:51


















          1














          Expo automatically do setup of jest.
          I think you must do 'Expo init newProject', then read .babelrc and package.json



          Below is result of expo init.
          It works well.



          // package.json

          "main": "node_modules/expo/AppEntry.js",
          "scripts":
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "eject": "expo eject",
          "test": "node ./node_modules/jest/bin/jest.js --watchAll"
          ,
          "jest":
          "preset": "jest-expo"
          ,
          "dependencies":
          "@expo/samples": "2.1.1",
          "expo": "^32.0.0",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          "react-navigation": "^3.0.9"
          ,
          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0"
          ,
          "private": true



          // babel.config.js
          module.exports = function(api)
          api.cache(true);
          return
          presets: ['babel-preset-expo'],
          ;
          ;






          share|improve this answer























          • You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

            – Bruno Eduardo
            Feb 5 at 13:26











          • For me it doesn't work.

            – J. Hesters
            Feb 13 at 18:15










          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%2f54524017%2fhow-to-configure-jest-to-work-with-expo-sdk-32%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          This is what solved the problem for me:



          • First thing, install yarn. Follow this link for instructions.

          • Second, ensure your package.json looks something like this:

          "dependencies": 
          "@expo/vector-icons": "9.0.0",
          "expo": "^32.0.0",
          "prop-types": "15.6.2",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          ...
          ,

          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0",
          ...

          "scripts":
          "test": "jest",
          ...
          ,
          "jest":
          "preset": "jest-expo",
          "transform":
          "^.+\.js$": "babel-jest"
          ,



          • Third, ensure your babel.config.js is setup correctly. Here's the one from my project running Expo's SDK 32:

          module.exports = function (api) 
          api.cache(true);
          return
          presets: [
          'babel-preset-expo',
          'module:react-native-dotenv',
          ],
          sourceMaps: true,
          plugins: [
          '@babel/transform-react-jsx-source',
          ],
          ;
          ;


          • Lastly, use yarn to install your packages (yarn install) and to run your tests yarn test.





          share|improve this answer

























          • Worked for me but can you explain why it works with yarn but not with npm ?

            – baraber
            Mar 6 at 15:06











          • @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

            – Bruno Eduardo
            Mar 6 at 16:23











          • That could make sense since it look like some dependency issue.

            – baraber
            Mar 6 at 20:51















          2














          This is what solved the problem for me:



          • First thing, install yarn. Follow this link for instructions.

          • Second, ensure your package.json looks something like this:

          "dependencies": 
          "@expo/vector-icons": "9.0.0",
          "expo": "^32.0.0",
          "prop-types": "15.6.2",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          ...
          ,

          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0",
          ...

          "scripts":
          "test": "jest",
          ...
          ,
          "jest":
          "preset": "jest-expo",
          "transform":
          "^.+\.js$": "babel-jest"
          ,



          • Third, ensure your babel.config.js is setup correctly. Here's the one from my project running Expo's SDK 32:

          module.exports = function (api) 
          api.cache(true);
          return
          presets: [
          'babel-preset-expo',
          'module:react-native-dotenv',
          ],
          sourceMaps: true,
          plugins: [
          '@babel/transform-react-jsx-source',
          ],
          ;
          ;


          • Lastly, use yarn to install your packages (yarn install) and to run your tests yarn test.





          share|improve this answer

























          • Worked for me but can you explain why it works with yarn but not with npm ?

            – baraber
            Mar 6 at 15:06











          • @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

            – Bruno Eduardo
            Mar 6 at 16:23











          • That could make sense since it look like some dependency issue.

            – baraber
            Mar 6 at 20:51













          2












          2








          2







          This is what solved the problem for me:



          • First thing, install yarn. Follow this link for instructions.

          • Second, ensure your package.json looks something like this:

          "dependencies": 
          "@expo/vector-icons": "9.0.0",
          "expo": "^32.0.0",
          "prop-types": "15.6.2",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          ...
          ,

          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0",
          ...

          "scripts":
          "test": "jest",
          ...
          ,
          "jest":
          "preset": "jest-expo",
          "transform":
          "^.+\.js$": "babel-jest"
          ,



          • Third, ensure your babel.config.js is setup correctly. Here's the one from my project running Expo's SDK 32:

          module.exports = function (api) 
          api.cache(true);
          return
          presets: [
          'babel-preset-expo',
          'module:react-native-dotenv',
          ],
          sourceMaps: true,
          plugins: [
          '@babel/transform-react-jsx-source',
          ],
          ;
          ;


          • Lastly, use yarn to install your packages (yarn install) and to run your tests yarn test.





          share|improve this answer















          This is what solved the problem for me:



          • First thing, install yarn. Follow this link for instructions.

          • Second, ensure your package.json looks something like this:

          "dependencies": 
          "@expo/vector-icons": "9.0.0",
          "expo": "^32.0.0",
          "prop-types": "15.6.2",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          ...
          ,

          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0",
          ...

          "scripts":
          "test": "jest",
          ...
          ,
          "jest":
          "preset": "jest-expo",
          "transform":
          "^.+\.js$": "babel-jest"
          ,



          • Third, ensure your babel.config.js is setup correctly. Here's the one from my project running Expo's SDK 32:

          module.exports = function (api) 
          api.cache(true);
          return
          presets: [
          'babel-preset-expo',
          'module:react-native-dotenv',
          ],
          sourceMaps: true,
          plugins: [
          '@babel/transform-react-jsx-source',
          ],
          ;
          ;


          • Lastly, use yarn to install your packages (yarn install) and to run your tests yarn test.






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Mar 6 at 16:30

























          answered Feb 13 at 18:59









          Bruno EduardoBruno Eduardo

          573213




          573213












          • Worked for me but can you explain why it works with yarn but not with npm ?

            – baraber
            Mar 6 at 15:06











          • @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

            – Bruno Eduardo
            Mar 6 at 16:23











          • That could make sense since it look like some dependency issue.

            – baraber
            Mar 6 at 20:51

















          • Worked for me but can you explain why it works with yarn but not with npm ?

            – baraber
            Mar 6 at 15:06











          • @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

            – Bruno Eduardo
            Mar 6 at 16:23











          • That could make sense since it look like some dependency issue.

            – baraber
            Mar 6 at 20:51
















          Worked for me but can you explain why it works with yarn but not with npm ?

          – baraber
          Mar 6 at 15:06





          Worked for me but can you explain why it works with yarn but not with npm ?

          – baraber
          Mar 6 at 15:06













          @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

          – Bruno Eduardo
          Mar 6 at 16:23





          @baraber not entirelly sure, but my guess is that npm downloads the wrong/old packages, while yarn installs the correct ones. As far as I know the Expo devs use Yarn so they must've tested SDK 32 with yarn only, which lead to these problems with the new version and npm installs.

          – Bruno Eduardo
          Mar 6 at 16:23













          That could make sense since it look like some dependency issue.

          – baraber
          Mar 6 at 20:51





          That could make sense since it look like some dependency issue.

          – baraber
          Mar 6 at 20:51













          1














          Expo automatically do setup of jest.
          I think you must do 'Expo init newProject', then read .babelrc and package.json



          Below is result of expo init.
          It works well.



          // package.json

          "main": "node_modules/expo/AppEntry.js",
          "scripts":
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "eject": "expo eject",
          "test": "node ./node_modules/jest/bin/jest.js --watchAll"
          ,
          "jest":
          "preset": "jest-expo"
          ,
          "dependencies":
          "@expo/samples": "2.1.1",
          "expo": "^32.0.0",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          "react-navigation": "^3.0.9"
          ,
          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0"
          ,
          "private": true



          // babel.config.js
          module.exports = function(api)
          api.cache(true);
          return
          presets: ['babel-preset-expo'],
          ;
          ;






          share|improve this answer























          • You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

            – Bruno Eduardo
            Feb 5 at 13:26











          • For me it doesn't work.

            – J. Hesters
            Feb 13 at 18:15















          1














          Expo automatically do setup of jest.
          I think you must do 'Expo init newProject', then read .babelrc and package.json



          Below is result of expo init.
          It works well.



          // package.json

          "main": "node_modules/expo/AppEntry.js",
          "scripts":
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "eject": "expo eject",
          "test": "node ./node_modules/jest/bin/jest.js --watchAll"
          ,
          "jest":
          "preset": "jest-expo"
          ,
          "dependencies":
          "@expo/samples": "2.1.1",
          "expo": "^32.0.0",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          "react-navigation": "^3.0.9"
          ,
          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0"
          ,
          "private": true



          // babel.config.js
          module.exports = function(api)
          api.cache(true);
          return
          presets: ['babel-preset-expo'],
          ;
          ;






          share|improve this answer























          • You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

            – Bruno Eduardo
            Feb 5 at 13:26











          • For me it doesn't work.

            – J. Hesters
            Feb 13 at 18:15













          1












          1








          1







          Expo automatically do setup of jest.
          I think you must do 'Expo init newProject', then read .babelrc and package.json



          Below is result of expo init.
          It works well.



          // package.json

          "main": "node_modules/expo/AppEntry.js",
          "scripts":
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "eject": "expo eject",
          "test": "node ./node_modules/jest/bin/jest.js --watchAll"
          ,
          "jest":
          "preset": "jest-expo"
          ,
          "dependencies":
          "@expo/samples": "2.1.1",
          "expo": "^32.0.0",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          "react-navigation": "^3.0.9"
          ,
          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0"
          ,
          "private": true



          // babel.config.js
          module.exports = function(api)
          api.cache(true);
          return
          presets: ['babel-preset-expo'],
          ;
          ;






          share|improve this answer













          Expo automatically do setup of jest.
          I think you must do 'Expo init newProject', then read .babelrc and package.json



          Below is result of expo init.
          It works well.



          // package.json

          "main": "node_modules/expo/AppEntry.js",
          "scripts":
          "start": "expo start",
          "android": "expo start --android",
          "ios": "expo start --ios",
          "eject": "expo eject",
          "test": "node ./node_modules/jest/bin/jest.js --watchAll"
          ,
          "jest":
          "preset": "jest-expo"
          ,
          "dependencies":
          "@expo/samples": "2.1.1",
          "expo": "^32.0.0",
          "react": "16.5.0",
          "react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
          "react-navigation": "^3.0.9"
          ,
          "devDependencies":
          "babel-preset-expo": "^5.0.0",
          "jest-expo": "^32.0.0"
          ,
          "private": true



          // babel.config.js
          module.exports = function(api)
          api.cache(true);
          return
          presets: ['babel-preset-expo'],
          ;
          ;







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 5 at 2:34









          sonicmariosonicmario

          143211




          143211












          • You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

            – Bruno Eduardo
            Feb 5 at 13:26











          • For me it doesn't work.

            – J. Hesters
            Feb 13 at 18:15

















          • You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

            – Bruno Eduardo
            Feb 5 at 13:26











          • For me it doesn't work.

            – J. Hesters
            Feb 13 at 18:15
















          You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

          – Bruno Eduardo
          Feb 5 at 13:26





          You pointed me to the right direction: it seems like it's a problem with NPM. When I created a new example project I noticed it used Yarn to download the dependencies. If I deleted the node_moduels folder and used npm install the tests would start breaking after that.

          – Bruno Eduardo
          Feb 5 at 13:26













          For me it doesn't work.

          – J. Hesters
          Feb 13 at 18:15





          For me it doesn't work.

          – J. Hesters
          Feb 13 at 18:15

















          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%2f54524017%2fhow-to-configure-jest-to-work-with-expo-sdk-32%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







          Popular posts from this blog

          Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

          Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

          Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved