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.

Typescript based configuration doesn't work when using simple preset setup

See original GitHub issue

I am trying to load a typescript config with jest-dynalite.

    Something went wrong reading your jest-dynalite-config.ts: Unexpected token 'export'

      at readConfig (../../node_modules/.pnpm/jest-dynalite@3.4.4_c6ac6979dbeefcbbac9c0114ae514571/node_modules/jest-dynalite/dist/config.js:42:15)
      at async TestScheduler.scheduleTests (../../node_modules/.pnpm/@jest+core@27.3.1/node_modules/@jest/core/build/TestScheduler.js:333:13)

Everything else in my project is TypeScript and works fine. I am having a babel.config.json.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
derolfcommented, Nov 4, 2021

Thanks for your quick response. Meanwhile, I am using dynalite directly (without jest-dynalite).

I have a setup.ts:

import dynalite from "dynalite";
import * as dynamodb from "@aws-sdk/client-dynamodb";
import * as db from "../src/db";

const dynaliteServer = dynalite({ createTableMs: 0, deleteTableMs: 0, updateTableMs: 0 });

process.env.AWS_REGION = "test";
process.env.AWS_ACCESS_KEY_ID = "test";
process.env.AWS_SECRET_ACCESS_KEY = "test";

beforeAll(async () => {
  await new Promise<void>((resolve) => dynaliteServer.listen(0, () => resolve()));
  const addr = dynaliteServer.address();
  if (!addr || typeof addr === "string") {
    // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
    throw new Error(`${addr}`);
  }

  db.setDdb(new dynamodb.DynamoDB({ endpoint: `http://localhost:${addr.port}` }));
});

beforeEach(async () => {
  await db.ddb.deleteTable({ TableName: "table" }).catch((_) => false);
  await db.ddb.createTable({
    TableName: "table",
    KeySchema: [
      { AttributeName: "pk", KeyType: "HASH" },
      { AttributeName: "id", KeyType: "RANGE" },
    ],
    AttributeDefinitions: [
      { AttributeName: "pk", AttributeType: "S" },
      { AttributeName: "id", AttributeType: "S" },
    ],
    BillingMode: "PAY_PER_REQUEST",
  });
});

afterAll(async () => {
  await new Promise<void>((resolve) => dynaliteServer.close(() => resolve()));
});

and just link it with: setupFilesAfterEnv: [path.join(__dirname, "test-helpers/setup.ts")], in my jest.config.js.

0reactions
revmischacommented, May 27, 2022

I get this error too using ES modules and jest-dynalite-config.ts: Something went wrong reading your jest-dynalite-config.ts: Unexpected token 'export'

I tried renaming the file to jest-dynalite-config.js - I get the error:

    Something went wrong reading your jest-dynalite-config.js: require() of ES Module /Users/cyber/dev/tombo/sequencer/jest-dynalite-config.js from /Users/cyber/dev/sequencer/node_modules/jest-dynalite/dist/config.js not supported.
    Instead change the require of jest-dynalite-config.js in /Users/cyber/dev/sequencer/node_modules/jest-dynalite/dist/config.js to a dynamic import() which is available in all CommonJS modules.

      at readConfig (node_modules/jest-dynalite/dist/config.js:42:15)
      at getDynalitePort (node_modules/jest-dynalite/dist/config.js:52:33)
      at exports.default (node_modules/jest-dynalite/dist/setup.js:6:47)
      at new DynaliteEnvironment (node_modules/jest-dynalite/dist/environment.js:22:33)
Read more comments on GitHub >

github_iconTop Results From Across the Web

TSConfig Reference - Docs on every TSConfig option
It has no interaction with the include , exclude , or files tsconfig.json settings. Note that TypeScript will never write an output file...
Read more >
A Complete Guide to Using TypeScript in Node.js - Better Stack
We need to set up a configuration file ( tsconfig.json ) for our project before we can start compiling our source files. If...
Read more >
TypeScript configuration - Angular
A given Angular workspace contains several TypeScript configuration files. At the root tsconfig.json file specifies the base TypeScript and Angular compiler ...
Read more >
Build an NPM Package in TypeScript from the Ground Up
The TypeScript compiler needs a tsconfig.json . I'm working with Node 18, so I'll start with this Node 18 base configuration from the...
Read more >
Monorepo Setup with NPM and TypeScript - In Plain English
VSCode and/or TypeScript doesn't detect/see the local package? node_modules; No workspaces found; EDUPLICATEWORKSPACE; npm WARN workspaces abc/ ...
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