You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Importing fileTypeFromBuffer using ES6 module with Node + TypeScript + jest throws an error, am I doing something wrong? (I also tried importing fileTypeFromFile and give the same error)
(error throws only while importing modules from 'file-type' package, other packages haven't given any trouble)
● The test suite failed to run
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box, Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Details:
/urs/src/app/node_modules/file-type/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import * as strtok3 from 'strtok3';
^^^^^^
SyntaxError: Cannot use import statement outside a module
1 | import { EmailAdapter, EmailAddress } from '@/any/directory'
2 |
> 3 | import { fileTypeFromBuffer } from 'file-type'
| ^
4 |
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
at Object.<anonymous> (any/directory/file.ts:3:1)
My npm script used for run tests:
"test": "jest --passWithNoTests --no-cache --runInBand",
"test:watch": "npm test -- --watch",
Importing
fileTypeFromBuffer
using ES6 module with Node + TypeScript + jest throws an error, am I doing something wrong? (I also tried importingfileTypeFromFile
and give the same error)(error throws only while importing modules from
'file-type'
package, other packages haven't given any trouble)My npm script used for run tests:
My
jest.config.js
:My
tsconfig.json
:Package versions:
Node version: v16.13.2
The text was updated successfully, but these errors were encountered: