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.

Description

I want to run tests. Might be related to: https://github.com/react-community/create-react-native-app/issues/199

Expected Behavior

Tests succeed.

Observed Behavior

Tests always fail. With a variety of syntax errors.

Environment

Please run these commands in the project folder and fill in their results:

  • npm ls react-native-scripts: 1.11.1
  • npm ls react-native: 0.52.0
  • npm ls expo: 25.0.0
  • node -v: v8.1.1
  • npm -v: 5.0.3
  • yarn --version: 1.3.2
  • watchman version: 4.7.0

Also specify:

  1. Operating system: Mac OSX High Sierra
  2. Phone/emulator/simulator & version: N/A

Reproducible Demo

I got only one test, it’s the default test CRNA creates.

I have created a minimal example of what makes CRNA fail when running yarn test.

It is after this commit where yarn test starts to fail https://github.com/watadarkstar/minimal-failing-crna-yarn-test/commit/94fdee722f773196f80b349f0d8ae970e4ed3d04

The minimal example can be found here: https://github.com/watadarkstar/minimal-failing-crna-yarn-test

I try to run it with yarn test

I get SyntaxError: Unexpected token import in many source files. I get this with the default package.json:

node_modules/native-base-shoutem-theme/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,global,jest){import connectStyle from "./src/connectStyle";
                                                                                             ^^^^^^

    SyntaxError: Unexpected token import

      1 | import React from 'react';
    > 2 | import { Text, View } from 'native-base';
      3 | import { StackNavigator } from 'react-navigation';
      4 | import { Home, Quiz, Results } from './components/screens';
      5 |

My .babelrc:

{
  "presets": ["babel-preset-expo"],
  "env": {
    "development": {
      "plugins": ["transform-react-jsx-source"]
    }
  }
}

My package.json:

"test": "node node_modules/jest/bin/jest.js"

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
idecommented, Feb 23, 2018

I’m not sure we can provide a more user-friendly message. Do you have ideas for how we could practically do that?

One fix people could apply on their own, if they want to bear the cost of more transforms, is to set transformIgnorePatterns: [].

0reactions
watadarkstarcommented, Feb 23, 2018

@ide I can agree from a technical perspective this works as expected once you dive into the issue. Although from a user’s perspective, many people will run into this issue as soon as they add a package that doesn’t need to be transpiled and then run yarn test. It would be nice if there was a more user-friendly solution.

Another alternative is to provide a more meaningful error message when these transpile errors occur in node_modules from Jest, but I don’t know enough about how Jest works.

Read more comments on GitHub >

github_iconTop Results From Across the Web

yarn test: all tests passed but returned "error Command failed ...
I used to use npm but recently switched to yarn. When I run yarn test it shows all tests passed but below says...
Read more >
Test fail while running yarn test · Issue #22326 · facebook/react
While running yarn test getting these failing tests- ... Tests pass for me - can you send the commands you're running?
Read more >
jest-fail-on-console | Yarn - Package Manager
Jest doesn't fail the tests when there is a console.error . In large codebase, we can end up with the test output overloaded...
Read more >
Troubleshooting - Jest
Tests are Failing and You Don't Know Why​. Try using the debugging ... Using yarn test (e.g. with create-react-app) yarn test --runInBand.
Read more >
Jest — Fail Early (And Stop Testing If One Test Fails)
It can be helpful to stop large test suites as soon as an error occurs. Stopping the test run after the first failed...
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