Skip to content

Instantly share code, notes, and snippets.

View Skn0tt's full-sized avatar

Simon Knott Skn0tt

View GitHub Profile
@timosadchiy
timosadchiy / jest.config.js
Last active September 22, 2023 05:46
Jest + Typescript. Resolve tsconfig.json paths.
/**
* Converts paths defined in tsconfig.json to the format of
* moduleNameMapper in jest.config.js.
*
* For example, {'@alias/*': [ 'path/to/alias/*' ]}
* Becomes {'@alias/(.*)': [ '<rootDir>/path/to/alias/$1' ]}
*
* @param {string} srcPath
* @param {string} tsconfigPath
*/