Jest runner for Remark.
jest-runner-remark
is best used alongside a remark-lint
configuration. See the documentation on configuring remark-lint
before continuing.
Install jest
and jest-runner-remark
npm install --save-dev jest jest-runner-remark
# or with yarn
yarn add --dev jest jest-runner-remark
This package includes a Jest preset which configures Jest to run Remark on all files supported by Remark. To use it set the following in your package.json:
{
"jest": {
"preset": "jest-runner-remark"
}
}
or jest.config.js:
module.exports = {
preset: "jest-runner-remark",
};
In your package.json
{
"jest": {
"runner": "remark",
"moduleFileExtensions": ["md", "mdx", "markdown", "mkd", "mkdn", "mkdown"],
"testMatch": [
"<rootDir>/**/*.md",
"<rootDir>/**/*.mdx",
"<rootDir>/**/*.markdown",
"<rootDir>/**/*.mkd",
"<rootDir>/**/*.mkdn",
"<rootDir>/**/*.mkdown"
]
}
}
Or in jest.config.js
module.exports = {
runner: "remark",
moduleFileExtensions: ["md", "mdx", "markdown", "mkd", "mkdn", "mkdown"],
testMatch: [
"<rootDir>/**/*.md",
"<rootDir>/**/*.mdx",
"<rootDir>/**/*.markdown",
"<rootDir>/**/*.mkd",
"<rootDir>/**/*.mkdn",
"<rootDir>/**/*.mkdown",
],
};
npx jest
# or with yarn
yarn jest