SolidJSS
SolidJSโ€ข3y agoโ€ข
1 reply
kerrick

Jest, TypeScript, and @solidjs/router

I set up my project with Jest & TypeScript according to https://www.solidjs.com/guides/testing#jest-with-typescript-ts-jest and while it seems to test simple components well, as soon as I try to test a component that uses imports from
@solidjs/router
, jest chokes. I tried reading the documentation linked in the error, but I didn't see anything obviously wrong. Do I need to set up additional configs for
@solidjs/router
or is there a bug in that package?

Here's a piece of the error:
    Details:

    /Users/kerrick/Developer/carbon-graphite/node_modules/@solidjs/router/dist/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import { isServer, delegateEvents, createComponent as createComponent$1, spread, mergeProps as mergeProps$1, template } from 'solid-js/web';
                                                                                      ^^^^^^

    SyntaxError: Cannot use import statement outside a module

      1 | import styles from './ClientsIndex.module.css';
    > 2 | import { A, useRouteData } from '@solidjs/router';
        | ^


Here's the full error, plus what I believe to be the relevant parts of my config files: https://gist.github.com/Kerrick/02e1a837ae3b6736b2cd826568c2ed5e
Was this page helpful?