ericclemmons / polydev

Faster, route-centric development for Node.js apps with built-in Hot Module Replacement.
282 stars 6 forks source link

Jest can't resolve routes correctly #37

Closed ericclemmons closed 5 years ago

ericclemmons commented 5 years ago

This is incredibly hard to troubleshoot, but it goes something like this:

  1. project/node_modules/polydev/src/middleware/router/handle.production.js attempts to require("project/example/routes/login/index.ts")
  2. Jest does a bunch of resolution stuff, and ends up loading project/index.js.
  3. Just incorrectly stores the module key as user:project/node_modules/polydev/src/middleware/router/handle.production.js:, because it can't resolve the absolute path or mock module location/meta.
ericclemmons commented 5 years ago

The absolutePath is null and mockPath is project/index.js.

https://github.com/facebook/jest/blob/72d01cc79f3dfe05419cd8dea1b6c9a558d93879/packages/jest-resolve/src/index.ts#L277-L279

ericclemmons commented 5 years ago

https://github.com/facebook/jest/blob/72d01cc79f3dfe05419cd8dea1b6c9a558d93879/packages/jest-resolve/src/__tests__/resolve.test.ts