question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

New project template does not have working Jest config

See original GitHub issue

Issue 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:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
pf1guracommented, Aug 7, 2020

I can confirm it works now. Thanks!

0reactions
rschristiancommented, Aug 7, 2020

Glad to hear it. Feel free to close this if you have no more issues.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found