Replies: 1 comment 9 replies
-
|
the error points out that |
Beta Was this translation helpful? Give feedback.
9 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having hard time to workaround the "SyntaxError: Cannot use import statement outside a module" issue. We don't use
babel, onlywebpackwithts-loader. Everything works well on run-time. But running tests fails:FAIL app/components/TreeTable/helpers.spec.ts ● Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript. By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules". Here's what you can do: • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/en/ecmascript-modules for how to enable it. • 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. You'll find more details and examples of these config options in the docs: https://jestjs.io/docs/en/configuration.html Details: /Users/kishu/Development/dev.azure.com/fundguard/fgrepo/client/node_modules/@nll/datum/DatumEither.js:22 import { left, isRight, isLeft, right, fromOption as eitherFromOption, fold as eitherFold, } from 'fp-ts/es6/Either'; ^^^^^^ SyntaxError: Cannot use import statement outside a module > 1 | import * as DE from '@nll/datum/DatumEither' | ^ 2 | import { ApolloQueryResult, QueryOptions } from 'apollo-client' 3 | import * as Rx from 'fp-ts-rxjs/Observable' 4 | import * as A from 'fp-ts/ReadonlyArray' at Runtime.createScriptFromCode (../../node_modules/jest-runtime/build/index.js:1350:14) at Object.<anonymous> (app/utils/Repository.ts:1:1)What should I do? I don't want to add
babel.Latest
TypeScript.Latest
jest.Latest
ts-jest.My
jest.config.json:{ "preset": "ts-jest", "testEnvironment": "jsdom" }My
tsconfig.json:{ "compilerOptions": { "allowJs": true, "baseUrl": "app", "jsx": "react", "module": "es6", "outDir": "build", "rootDir": "app", "sourceMap": true }, "exclude": ["**/*.js"], "extends": "../tsconfig.settings.json" }My
../tsconfig.settings.json:{ "compilerOptions": { "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "importHelpers": true, "incremental": true, "lib": ["es2019", "dom"], "module": "commonjs", "moduleResolution": "node", "noFallthroughCasesInSwitch": true, "noImplicitReturns": true, "noUnusedLocals": true, "noUnusedParameters": true, "resolveJsonModule": true, "skipLibCheck": true, "sourceMap": false, "strict": true, "target": "es5" } }Beta Was this translation helpful? Give feedback.
All reactions