A simple jest transformer for MDX with frontMatter support.
yarn add jest-transformer-mdx
// jest.config.js
module.exports = {
// A map from regular expressions to paths to transformers
transform: {
"^.+\\.(md|mdx)$": 'jest-transformer-mdx',
},
};And that should be it! jest-transformer-mdx will pick up your babel config and use your jest config.
Look inside this library's test and the related markdown file to see live a example.
You can also use this module in create-react-app-like apps where the config is not exposed. Just edit your transform property to import from jest-transformer-mdx/cra
// jest.config.js
module.exports = {
transform: {
"^.+\\.(md|mdx)$": 'jest-transformer-mdx/cra',
},
};Made possible by