Skip to content
This repository has been archived by the owner on Jan 8, 2021. It is now read-only.

Jest issue: Cannot find module 'jose/jwt/verify' from 'node_modules/ts-dpop/dist/access-token.js' #13

Closed
RubenVerborgh opened this issue Nov 26, 2020 · 3 comments

Comments

@RubenVerborgh
Copy link

No description provided.

@matthieubosquet
Copy link
Owner

Getting Jest to behave with Jose was a fun issue to solve involving adding a moduleNameMapper and testEnvironment to the jest config as well as adding DOM to the TypeScript compiler options libraries (there is a growing issue for overlapping node and browser APIs, see also: microsoft/TypeScript#41727).

ts-dpop/jest.config.js

Lines 1 to 20 in 5e61dfe

module.exports = {
preset: "ts-jest",
testEnvironment: "node",
testRegex: "/test/.*\\.test\\.ts$",
testRunner: "jest-circus/runner",
testTimeout: 1000,
coverageDirectory: "./coverage/",
collectCoverage: true,
coverageThreshold: {
global: {
branches: 100,
functions: 100,
lines: 100,
statements: 100,
},
},
moduleNameMapper: {
"^jose/(.*)$": "<rootDir>/node_modules/jose/dist/node/cjs/$1",
},
};

"lib": [ "DOM", "es2019", "es2020.promise", "es2020.bigint", "es2020.string" ],

@RubenVerborgh
Copy link
Author

👍👍 cool work, did you let the author know?

@matthieubosquet
Copy link
Owner

matthieubosquet commented Dec 27, 2020

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants