Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
MongoDb can't use types in jest - declares ... locally, but it is not exported

I use the mongodb library in TypeScript for a few functions (e.g. lambda functions but that should not matter).

The imports look like that:

import { ObjectId, Db, InsertOneResult } from "mongodb";

When I import the function in Jest and execute it I always get the error:

Module '"../../node_modules/mongodb/mongodb.ts34"' declares 'ObjectId' locally, but it is not exported.

I think something is wrong with my jest logic but I am not sure what. The function itself is working.

My jest config looks like that:

const tsPreset = require("ts-jest/jest-preset");

module.exports = {
  ...tsPreset,
  testEnvironment: "node",
  roots: ["<rootDir>/test"],
  testMatch: ["**/*.test.ts"],
  moduleNameMapper: {
    "^@/types/(.*)$": "<rootDir>/types/$1",
    "^@/lib/(.*)$": "<rootDir>/lib/$1",
    "^@/functions/(.*)$": "<rootDir>/functions/$1",
  },
};

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

This appears to be related to this ticket. The current versions of the mongodb node driver are no longer compatible with typescript 3.9.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!