question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error on Galio files when run tests with jest

See original GitHub issue

Describe the bug Got an error when galio is imported by tested file. I’m not sure if it’s a problem with Galio or Jest. Jest was configured like expo docs suggests.

/home/felipe/Dev/GoAppDesign/node_modules/galio-framework/src/index.js:4
    import Accordion from './Accordion';
           ^^^^^^^^^

    SyntaxError: Unexpected identifier

      2 | import { StyleSheet } from 'react-native';
      3 | import PropTypes from 'prop-types';
    > 4 | import { Button } from 'galio-framework';
        | ^
      5 | 
      6 | import { argonTheme } from '../constants';
      7 | 

      at Runtime.createScriptFromCode (node_modules/@jest/core/node_modules/jest-runtime/build/index.js:1059:14)
      at Object.<anonymous> (src/argon/Button.js:4:1)

To Reproduce Steps to reproduce the behavior:

  1. A published a minimal project that reproduces the error
  2. Clone https://github.com/felipebergamin/reproduce-galio-test-error
  3. Install deps with yarn
  4. Run test with yarn jest

Expected behavior Success test

Screenshots galio-error

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
davidsierradzcommented, Jul 2, 2020

Hi, I have:

  "jest": {
    "preset": "react-native",
    "transformIgnorePatterns": [
      "node_modules/(?!(react-native|galio-framework|react-native-vector-icons)/)"
    ]
  }

This fixes OP error. But now I’m getting this one:

yarn run v1.22.4
$ jest
 FAIL  __tests__/App-test.js
  ● Test suite failed to run

    /home/neuromante/code/mobile/node_modules/galio-framework/src/fonts/galio.ttf:1



    SyntaxError: Invalid or unexpected token

      at Runtime._execModule (node_modules/jest-runtime/build/index.js:1166:56)
      at Object.<anonymous> (node_modules/galio-framework/src/index.js:23:19)

Test Suites: 1 failed, 1 total
Tests:       0 total
Snapshots:   0 total
Time:        3.241 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
1reaction
palingheorghecommented, Mar 3, 2020

Hi @felipebergamin ! Thanks for opening up this issue. I’ll have to take a look at this, right now I’m not sure where exactly is the problem and why is this error showing up.

Read more comments on GitHub >

github_iconTop Results From Across the Web

0 - Stack Overflow
I modified my jest configuration to add this: "moduleNameMapper": { + "galio": "identity-obj-proxy" }. And installed the identity-obj-proxy ...
Read more >
Troubleshooting - Jest
Troubleshooting. Uh oh, something went wrong? Use this guide to resolve issues with Jest. Tests are Failing and You Don't Know Why​.
Read more >
Issues · galio-org/galio · GitHub
Error on Galio files when run tests with jest Type: Bug Something isn't working Type: Question Further information is requested.
Read more >
galio-community/Lobby - Gitter
@AmityTek I can't really understand your error message. ... @palingheorghe Yes, I am using Expo Snack to test galio framework components.
Read more >
git ignore for react native
Jest ignore or exclude file/function/statement from test coverage. If a file hasn't been added to git then you can add file to gitignore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found