2023-02-09 05:02:40 +08:00
|
|
|
# Jest config for Flarum
|
|
|
|
|
|
|
|
This package provides a [Jest](https://jestjs.io/) config object to run unit & integration tests on Flarum extensions.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
2024-09-28 22:47:45 +08:00
|
|
|
- Install the package: `yarn add --dev @flarum/jest-config`
|
|
|
|
- Add `"type": "module"` to your `package.json`
|
|
|
|
- Add `"test": "yarn node --experimental-vm-modules $(yarn bin jest)"` to your `package.json` scripts
|
|
|
|
- Rename `webpack.config.js` to `webpack.config.cjs`
|
|
|
|
- Create a `jest.config.cjs` file with the following content:
|
|
|
|
|
2023-02-09 05:02:40 +08:00
|
|
|
```js
|
2023-02-13 00:45:00 +08:00
|
|
|
module.exports = require('@flarum/jest-config')();
|
2023-02-09 05:02:40 +08:00
|
|
|
```
|
2024-09-28 22:47:45 +08:00
|
|
|
|
|
|
|
- If you are using TypeScript, create `tsconfig.test.json` with the following content:
|
|
|
|
|
2023-02-11 06:02:50 +08:00
|
|
|
```json
|
|
|
|
{
|
|
|
|
"extends": "./tsconfig.json",
|
|
|
|
"include": ["tests/**/*"],
|
2023-02-13 00:45:00 +08:00
|
|
|
"files": ["../../../node_modules/@flarum/jest-config/shims.d.ts"]
|
2023-02-11 06:02:50 +08:00
|
|
|
}
|
|
|
|
```
|