Open MaryamAdnan3 opened 4 months ago
I have a similar issue. It seems to me that for some reason ts-jest instructs the typescript compiler to emit ES3/ES5 code. I cannot pinpoint where this is happening though
This error indicates that Jest tried to process axios
but axios
is not passed (by Jest) to ts-jest
to transform.
Usually, this can be solved by configuring transformIgnoredPattern
option in Jest config file or moduleNameMapper
to tell Jest to resolve CJS version of axios
.
You can also use Jest ESM mode to process ESM axios file.
I think I'm having the same issue https://github.com/karpikpl/typescript-esm-sample
I tried using transformIgnoredPattern
but no luck :(
SyntaxError: Cannot use import statement outside a module
> 1 | import { graphql } from '@octokit/graphql'
this seems to have no effect:
"transformIgnorePatterns": [
"node_modules/(?!(@octokit/graphql|@octokit/request))"
],
Detail:
I have updated a third party library axios version to 1.6.7 . When I ran tests I started to get the following error ` Jest encountered an unexpected token
package.json
jest.config.js `const { jest: lernaAliases } = require('lerna-alias');
module.exports = { preset: 'ts-jest', moduleNameMapper: lernaAliases(), transform: { '^.+\.tsx?$': 'ts-jest', // Add TypeScript transformation '^.+\.jsx?$': 'babel-jest', // Add Babel transformation for ES6 modules }, coverageReporters: [['lcov', { projectRoot: '../../' }]] }; `