New project template does not have working Jest config
See original GitHub issueIssue summary
When creating new project with this template, tests generated for header component do not pass. It seems that TypeScript config is messed up when running Jest, as process errors out on first type declaration in the component
Details
SyntaxError: [...]/src/components/header/index.tsx: Unexpected token (5:12)
3 | import * as style from "./style.css";
4 |
> 5 | const Header: FunctionalComponent = () => {
| ^
6 | return (
7 | <header class={style.header}>
8 | <h1>Preact App</h1>
at Object._raise (node_modules/@babel/parser/src/parser/error.js:60:45)
at Object.raiseWithData (node_modules/@babel/parser/src/parser/error.js:55:17)
at Object.raise (node_modules/@babel/parser/src/parser/error.js:39:17)
at Object.unexpected (node_modules/@babel/parser/src/parser/util.js:152:16)
at Object.parseVar (node_modules/@babel/parser/src/parser/statement.js:1005:18)
at Object.parseVarStatement (node_modules/@babel/parser/src/parser/statement.js:686:10)
at Object.parseStatementContent (node_modules/@babel/parser/src/parser/statement.js:209:21)
at Object.parseStatement (node_modules/@babel/parser/src/parser/statement.js:149:17)
at Object.parseBlockOrModuleBlockBody (node_modules/@babel/parser/src/parser/statement.js:861:25)
at Object.parseBlockBody (node_modules/@babel/parser/src/parser/statement.js:833:10)
Steps to reproduce
preact create typescript projectName
cd projectName
npm run test
Additional information
When creating new project with widget-typescript template, Jest tests work just fine, but it seems they have different configuration.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Configuring Jest
The Jest philosophy is to work great by default, but sometimes you just need more configuration power.
Read more >Jest fails to load jest.config.ts in a ESM project using ts-node 10
In a project using TypeScript, Jest and setup as ESM (the output of the transpiler is ESM so Node will run ESM instead...
Read more >Jest - Could not locate module with dynamic import template ...
here's how I fixed it, the problem is that Jest for some reason, it complains when using template literals inside the dynamic import....
Read more >Setting up a project with jest in TypeScript. - ITNEXT
js beside npm . The TypeScript compiler can help us to create a tsconfig.json from a template with the following command: npx tsc...
Read more >Run/Debug Configuration: Jest | IntelliJ IDEA Documentation
In this dialog, create configurations for running Jest tests. ... run configuration (but not a run configuration template), you can specify ...
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 FreeTop 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
Top GitHub Comments
I can confirm it works now. Thanks!
Glad to hear it. Feel free to close this if you have no more issues.