open-index/open-npm huggingface dataset:
npm package: @oinpanel/jest-preset-oinpanel-admin
Description: Jest Test preset for OinPanel administration unit tests
Latest version: 6.0.1

# Jest Test preset for OinPanel administration unit tests


Default [Jest](https://jestjs.io/) preset for OinPanel 6 administration development.

```bash
npm install jest @oinpanel/jest-preset-oinpanel-admin @babel/preset-env @babel/plugin-proposal-class-properties --save-dev
```

## Setup

After installaing the necessary required packages, please create a file called `babel.config.json` right next to your own `package.json` with the following content:

```json
{
    "presets": ["@babel/preset-env"],
    "plugins": ["@babel/plugin-proposal-class-properties"]
}
```

### Via `jest.config.js`

Next up, create a file `jest.config.js` which should contain the following content:

```js
module.exports = {
    preset: '@oinpanel/jest-preset-oinpanel-admin',
    globals: {
        adminPath: '<file-path-to-oinpanel-administration>', // required, e.g. /platform/src/Administration/Resources/app/administration
    }
}
```

## Options the preset sets up for you

* `collectCoverage` - Code coverage will be generated using the reporters listed under `coverageReporters`
* `coverageReporters` - The presets uses `lcov`, `text` & `clover` as coverage reporters
* `watchPathIgnorePatterns` - Ignores the `node_modules` folder for the watch mode of Jest
* `clearMocks` - Automatically clear mock calls and instances before every test. 
* `moduleFileExtensions` - File with the extension `js` will automatically used as extensions your module use.
* `moduleNameMapper` - All `css`, `less` & `scss` files will be mocked and relative paths to `src` are getting mapped to the correct src directory
* `transform` - Transforms `js` files using [babel-jest](https://www.npmjs.com/package/babel-jest) and `twig` files are transformed using a custom twig transformer which we use in the administration as well
* `modulePathIgnorePatterns` - Ignores e2e test specs by default
* `setupFilesAfterEnv` - Provides a polyfill for Webpack' `require.context` and sets up the global OinPanel third-party interface for every test. The object can be accessed using `global.OinPanel` in test files.
* `testMatch` - Matches all files containing `.spec.js` in the test directory