0.1.1 • Published 6 years ago

jest-mdx-loader v0.1.1

Weekly downloads
43
License
MIT
Repository
github
Last release
6 years ago

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