0

I'm trying to test visual aspects of a react component, when rendering my component in a test my tests fail due to an "unexpected token export" that I believe is coming from firebase.

I don't wish to test firebase, though it is preventing my tests from running.

I'm getting the below error:

/Users/me/Desktop/Projects/Personal/myapp/node_modules/firebase/database/dist/index.esm.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){export * from '@firebase/database';
                                                                                      ^^^^^^

    SyntaxError: Unexpected token 'export'

    > 1 | import { update, ref, get } from 'firebase/database';

If possible - I would simply like to "ignore" firebase, so I can test my component.

Any help would be great - I've scoured the internet for the last few hours and nothing seems to work, so I think I'm looking in the wrong places.

Thanks

Nick
  • 2,261
  • 5
  • 33
  • 65
  • Does this answer your question? [How can I exclude files from Jest watch?](https://stackoverflow.com/questions/40486567/how-can-i-exclude-files-from-jest-watch) – Kundan May 10 '22 at 12:38
  • Did you fix this issue? Banging my head here over the past few days and can't find a solution. Thanks! – avcajaraville Dec 21 '22 at 17:57

1 Answers1

0

Add folder path in the "jest" object in your package.json file

"testPathIgnorePatterns": ["src/firebase" or "dist/src/firebase"] 

Read more here

sid
  • 1,779
  • 8
  • 10