sindresorhus / screenfull

Simple wrapper for cross-browser usage of the JavaScript Fullscreen API
https://sindresorhus.com/screenfull
MIT License
7.08k stars 698 forks source link

Issue in jest test cases if screenfull is imported inside any jsx #222

Closed pavanKumarTGMERN closed 1 year ago

pavanKumarTGMERN commented 1 year ago

If I use the screenfull library as shown below

import screenfull from 'screenfull';

The jest would throw the error as shown below

SyntaxError: Unexpected token 'export'

> 1 | import screenfull from 'screenfull';

By default "node_modules" folder is ignored by transformers.

Here's what you can do:
 • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
 • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
 • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
 • If you need a custom transformation specify a "transform" option in your config.
 • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

Please suggest on avoiding this import error

sindresorhus commented 1 year ago

This is not a problem with this package. Try asking on the Jest issue tracker instead.