@flarum/jest-config
v2.1.1
Published
Jest config for Flarum.
Keywords
Readme
Jest config for Flarum
This package provides a Jest config object to run unit & integration tests on Flarum extensions.
Usage
- Install the package:
yarn add --dev @flarum/jest-config - Add
"type": "module"to yourpackage.json - Add
"test": "yarn node --experimental-vm-modules $(yarn bin jest)"to yourpackage.jsonscripts - Rename
webpack.config.jstowebpack.config.cjs - Create a
jest.config.cjsfile with the following content:
module.exports = require('@flarum/jest-config')();- If you are using TypeScript, create
tsconfig.test.jsonwith the following content:
{
"extends": "./tsconfig.json",
"include": ["tests/**/*"],
"files": ["../../../node_modules/@flarum/jest-config/shims.d.ts"]
}Troubleshooting
symbol.charCodeAt is not a function when a test imports Flarum's source
If Babel fails on a regular expression such as /[^\p{L}\p{N}]/u with TypeError: symbol.charCodeAt is not a function, your yarn.lock holds two copies of regenerate. This can happen after upgrading a single package, which keeps the old regenerate@^1.4.2 entry next to the regenerate@^1.5.0 that newer Babel releases need.
Delete the regenerate@^1.4.2 block from yarn.lock and run yarn install. Both ranges then resolve to one copy.
