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.

Jest tests: 'return' outside of function

See original GitHub issue

Goals

When i run jest test component should not have errors.

Expected Results

No errors

Actual Results

 28 | if ('REALM_DISABLE_ANALYTICS' in process.env) {
        29 |     module.exports = function(){};
      > 30 |     return;
           |     ^
        31 | }
        32 |
        33 | const os = require('os');

Steps to Reproduce

Code Sample

Version of Realm and Tooling

  • Realm JS SDK Version: latest
  • Node or React Native: latest
  • Client OS & Version: latest
  • Which debugger for React Native: ?/None

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:6
  • Comments:14 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
EJohnFcommented, Nov 13, 2017

@bang88 try to modify your package.json: “jest”: { “preset”: “react-native”, “transformIgnorePatterns”: [ “node_modules/(realm)/” ] }

it helps me

2reactions
dkpalmercommented, Jul 3, 2018

I was able to resolve the issue with the following in .babelrc:

"parserOpts": {
  "allowReturnOutsideFunction": true,
},
Read more comments on GitHub >

github_iconTop Results From Across the Web

Mock Functions - Jest
Mock functions allow you to test the links between code by erasing the actual implementation of a function, capturing calls to the function ......
Read more >
When running a Jest test, a variable outside the function is ...
After running the test, there is an error. ReferenceError: proxy is not defined. I have solved this error by mocking the module below...
Read more >
Testing JavaScript with Jest - Flavio Copes
Jest is a library for testing JavaScript code. It's an open source project ... With functions that return promises, we return a promise...
Read more >
How to use Jest spyOn with React.js and Fetch - Meticulous
Good testing involves mocking out dependencies. Jest provides multiple ways to mock out dependencies while writing unit tests. The most common ...
Read more >
Globals · Jest
Runs a function after all the tests in this file have completed. If the function returns a promise, Jest waits for that promise...
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