TS jest.config.ts error: SyntaxError: Unexpected token 'export'
See original GitHub issue🐛 Bug Report
Using jest.config.ts
and running jest
I get the following error:
Error: Jest: Failed to parse the TypeScript config file /Users/rafael/dev/maintained/detect-it/jest.config.ts
SyntaxError: Unexpected token 'export'
I have TypeScript setup for es modules, but maybe there is something else I’m missing, tsconfig.json
here. I installed ts-node
and copied the jest.config.ts
from the docs.
To Reproduce
Create jest.config.ts
:
import type {Config} from '@jest/types';
const config: Config.InitialOptions = {
verbose: true,
};
export default config;
Run npx jest
Expected behavior
For jest.config.ts
to parse and tests to run.
Link to repl or repo (highly encouraged)
Trying to convert the jest config from js to ts in this repo branch: https://github.com/rafgraph/detect-it/tree/jest-ts-config
envinfo
System:
OS: macOS 10.15.7
CPU: (8) x64 Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
Binaries:
Node: 12.18.3 - ~/.n/bin/node
Yarn: 1.22.5 - ~/.n/bin/yarn
npm: 6.14.8 - ~/.n/bin/npm
npmPackages:
jest: ^26.6.0 => 26.6.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Unexpected token export, when import not compiled libraries ...
FAIL src/index.test.js ○ Test suite failed to run Jest encountered an unexpected token This usually means that you are trying to import a...
Read more >Jest gives an error: "SyntaxError: Unexpected token export"
This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it...
Read more >TypeScript Jest: Unexpected Token Export - Reddit
I'm trying to run unit tests for a TypeScript project which uses another TypeScript project I've created as a dependency. However, despite ...
Read more >jest syntaxerror: unexpected token export - You.com | The AI ...
This means, that a file is not transformed through TypeScript compiler, e.g. because it is a JS file with TS syntax, or it...
Read more >SyntaxError: Unexpected token export - velog
Actual Code Solution · 1) .babelrc.json · transform-es2015-modules-commonjs · 2) jest.config.ts · ts-jest · babel-jest · 3) package.json.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Out in 26.6.1
@Gamote I am also having the same issue on a brand new project. Thanks for looking into this!