jest-mdx-loader

0.1.1 • Public • Published

jest-mdx-loader

Jest transformer that wraps mdx-js/mx webpack loader

Install

yarn add --dev jest-mdx-loader

Usage

Install jest-mdx-loader and then add it to your jest.config.js under transform:

/// jest.config.js
 
module.exports = {
  //...
  transform: {
    "^.+\\.jsx?$": "babel-jest",
    ".mdx?$": "jest-mdx-loader"
  }
  //...
};

If you need to perform any additional pre-processing prior to parsing with mdx you can easily extend the loader as follows:

// src/my-custom-jest-mdx-loader.js
 
preMdxParseCallback = function(src) {
  var modifiedSrc = src;
 
  // CUSTOM LOGIC HERE
 
  return modifiedSrc;
};
 
module.exports = {
  process: createTransformer(preMdxParseCallback)
};
/// jest.config.js
 
module.exports = {
  //...
  transform: {
    "^.+\\.jsx?$": "babel-jest",
    ".mdx?$": "<rootDir>/src/my-custom-jest-mdx-loader.js"
  }
  //...
};

Licence

MIT © Joseph Black

Readme

Keywords

Package Sidebar

Install

npm i jest-mdx-loader

Weekly Downloads

1

Version

0.1.1

License

MIT

Unpacked Size

28.7 kB

Total Files

6

Last publish

Collaborators

  • josephconradblack