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.

šŸ› Bug Report

All of my tests fails all of a sudden.

The error is quite vague and low-level. I am not sure exactly what should I do and what it means…

I have tried: - installed jest globally - uninstalling jest globally and running it locally (jest 24.8.0) - changed my node version lower and upper (currently using 10, tried 8, and it was working previously with 10)

describe('Test', () => {

    test('That simple', () => {
        expect(true).toEqual(true);
    });
});


I have a file that sets up the environment for my tests like this:

/**
 * Defines the React 16 Adapter for Enzyme. 
 *
 * @link http://airbnb.io/enzyme/docs/installation/#working-with-react-16
 * @copyright 2017 Airbnb, Inc.
 */
// const enzyme = require("enzyme");
// const Adapter = require("enzyme-adapter-react-16");

// enzyme.configure({ adapter: new Adapter() });

// setup file
import { configure } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

configure({ adapter: new Adapter() });

Below is the error that I get…

  ā— Test suite failed to run

    SyntaxError: Unexpected token m in JSON at position 0
        at JSON.parse (<anonymous>)

      3 |  *
      4 |  * @link http://airbnb.io/enzyme/docs/installation/#working-with-react-16
    > 5 |  * @copyright 2017 Airbnb, Inc.
        |               ^
      6 |  */
      7 | // const enzyme = require("enzyme");
      8 | // const Adapter = require("enzyme-adapter-react-16");

      at Runtime._loadModule (node_modules/jest-runtime/build/index.js:568:59)
      at Object.<anonymous> (node_modules/entities/lib/decode_codepoint.js:1:106)
      at Object.<anonymous> (node_modules/htmlparser2/lib/Tokenizer.js:3:23)
      at Object.<anonymous> (node_modules/htmlparser2/lib/Parser.js:1:106)
      at Object.<anonymous> (node_modules/htmlparser2/lib/index.js:1:103)
      at Object.<anonymous> (node_modules/cheerio/lib/parse.js:4:18)
      at Object.<anonymous> (node_modules/cheerio/lib/cheerio.js:5:13)
      at Object.<anonymous> (node_modules/cheerio/index.js:5:28)
      at Object.<anonymous> (node_modules/enzyme/build/ReactWrapper.js:15:16)
      at Object.<anonymous> (node_modules/enzyme/build/index.js:3:21)
      at Object.<anonymous> (src/test-setup.js:5:15)

To Reproduce

I am not sure? but my environment is:


npx: installed 1 in 1.505s

  System:
    OS: macOS High Sierra 10.13.6
    CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
  Binaries:
    Node: 8.11.3 - ~/.nvm/versions/node/v8.11.3/bin/node
    Yarn: 1.12.1 - /usr/local/bin/yarn
    npm: 5.10.0 - ~/Documents/workspace/ISR/mylotto-web-mobile/node_modules/.bin/npm
  npmPackages:
    jest: 24.7.1 => 24.7.1

Expected behavior

Test to run normally and pass…

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
nunisacommented, May 23, 2019

I faced the same issue but after hours of googling around in vain, the following change fixed it.

"transformIgnorePatterns": [
  "node_modules/(?!(babel-jest)/)"
]

So, it seems babel-jest was ignored all the time. But, I’m still surprised that this was never required because everything was working and tests were passing with "jest": "^24.7.1" and "babel-jest": "^24.7.1". Find my full configurations here.

Hope this helps!

0reactions
sag1vcommented, Jul 22, 2019

@nunisa This is exactly why i’m here, we also upgraded jest and all of a sudden we need to use transformIgnorePatterns

Read more comments on GitHub >

github_iconTop Results From Across the Web

What To Do When Tests Fail? - TestProject
Tests usually fail due to server and network issues, an unresponsive application or validation failure, or scripting issues. When failures occurĀ ...
Read more >
How to Fix Flaky Tests - Semaphore CI
Randomly failing tests are the hardest to debug. Here's a framework you can use to fix them and keep your test suite healthy....
Read more >
Test Failure Analysis Best Practices - Sauce Labs
Test failure analysis is what it sounds like: it's the process of analyzing a failed test to figure out what went wrong. ......
Read more >
15 Silly Mistakes ("Automatic Fails") That Prevent You From ...
The practical DMV test is the last step before getting your driving license. Here are 15 silly mistakes ("automatic fails") that prevent you...
Read more >
Test to Pass vs. Test to Fail - Software Testing - Beta Breakers
Testing to fail entails pushing a product to its limits by running it through a range of demanding scenarios. When QA testing is...
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