Skip to content

Wrongfully downloading binaries on CircleCi even tho they are cached #682

@goldylucks

Description

@goldylucks

Versions

  • NodeJS: v17.6.0
  • mongodb-memory-server-*: 8.8.0
  • mongodb(the binary version): 0.0.0
  • mongodb(the js package): 0.0.0
  • mongoose: 6.4.7
  • system: ubuntu 20.04

package:
mongo-memory-server

What is the Problem?

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:

image

However then down the line when I run my tests:

image

in addition, the SYSTEM_BINARY env variable is set to the path where the binary is.

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)
  }),
}))

Do you know why it happenes?

no

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions