mongodb memory server Wrongfully downloading binaries on CircleCi even tho they are cached

Viewed 47

Im using mongodb memory server.

Locally everything passes, but on circle ci it tries to download the binary even tho it's already there.

By running node node_modules/mongodb-memory-server/postinstall.js on CircleCi I see this output:

enter image description here However then down the line when I run my tests it tries to download the binary again:

enter image description here in addition, the SYSTEM_BINARY env variable is set to the path where the binary is.

Versions

  • NodeJS: v17.6.0
  • mongodb-memory-server-*: 8.8.0
  • mongoose: 6.4.7
  • system: ubuntu 20.04

Code Example

// .circleci.config.yml
version: 2.1

orbs:
  node: circleci/node@5.0.2

jobs:
  main:
    docker:
      - image: cimg/node:lts-browsers
    steps:
      - checkout
      - node/install-packages:
          pkg-manager: yarn
      - run: echo $SYSTEM_BINARY
      - run: node node_modules/mongodb-memory-server/postinstall.js
      - run: yarn test:api

workflows:
  build:
    jobs:
      - main

// mock-db-test-util.js
import { MongoMemoryServer } from "mongodb-memory-server"
import mockMongoose from "mongoose"

const mockMongoMemoryServer = MongoMemoryServer.create()

// @ts-ignore
jest.mock("../../src/db", () => ({
  // @ts-ignore
  ...(jest.requireActual("../../src/db").default as any),
  // @ts-ignore
  connect: jest.fn().mockImplementation(async () => {
    const mongo = await mockMongoMemoryServer
    const uri = mongo.getUri()
    await mockMongoose.connect(uri)
  }),
}))

0 Answers
Related