From beeb24ee89ea4a47cc298c677594458887a1d1ad Mon Sep 17 00:00:00 2001 From: Eric Clemmons Date: Fri, 15 Mar 2019 19:32:56 -0700 Subject: [PATCH] Use require.requireActual because Jest's resolver doesn't work with polydev --- src/middleware/router/handle.production.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/middleware/router/handle.production.js b/src/middleware/router/handle.production.js index 5e3bc87..810b653 100644 --- a/src/middleware/router/handle.production.js +++ b/src/middleware/router/handle.production.js @@ -1,5 +1,12 @@ const debug = require("debug")("polydev") +// ! Jest has a built-in mocking mechanism that can't correctly resolve project +// ! files from node_modules: +// @see https://github.com/facebook/jest/blob/72d01cc79f3dfe05419cd8dea1b6c9a558d93879/packages/jest-resolve/src/index.ts#L277-L279 +// +// @ts-ignore +if (require.requireActual) require = require.requireActual + module.exports = async function handle(router, file, routes) { await Promise.all( routes.map(async ([httpMethod, route]) => {