# @conterra/mapapps-mocha-runner

> A support lib for mocha test integration into map.apps.

Latest version **1.1.1** (published 2023-04-21) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @conterra/mapapps-mocha-runner
pnpm add @conterra/mapapps-mocha-runner
yarn add @conterra/mapapps-mocha-runner
bun add @conterra/mapapps-mocha-runner
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2023-04-21 |
| First published | 2021-08-13 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 21.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | conterra |
| Maintainers | a.frank, jessebluemr, schneiderlars, julkuh, m-scherpi, mbeckem_conterra, conterrade |
| Keywords | mapapps |

## Links

- npm: https://www.npmjs.com/package/@conterra/mapapps-mocha-runner
- Repository: https://github.com/conterra/ct-mapapps-mocha-runner
- Homepage: https://github.com/conterra/ct-mapapps-mocha-runner#readme
- Issues: https://github.com/conterra/ct-mapapps-mocha-runner/issues
- npm.io page: https://npm.io/package/@conterra/mapapps-mocha-runner

## Recent versions

- 1.1.1 (latest) — 2023-04-21
- 1.1.0 — 2023-04-14
- 1.0.1 — 2022-07-17
- 1.0.0 — 2021-08-13

## README

# @conterra/mapapps-mocha-runner

A support lib for mocha as test runner in map.apps based projects.
See <https://mochajs.org/> how to write tests.
The runner initializes the [bdd](https://mochajs.org/#bdd) test style of mocha.

## Usage

If the module is available within the js-registry, tests can be executed with an URL like this:

<http://localhost:8080/resources/jsregistry/root/@conterra/mapapps-mocha-runner/latest/mocha.html?boot=/js/tests/test-base/test-init.js&timeout=5000&registerInternAdapter=true&test=apprt-core/tests/intern-all>

This URL will load a `test-init.js` file, which configures the AMD loader.
It will enable the `intern` adapter to allow execution of old `intern` based tests.
And it executes all tests specified by `apprt-core/tests/intern-all`.

Possible URL parameters are:

| Name                  | Description                                                                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
| boot                  | comma separated list of initialization files                                                                                                |
| test                  | comma separated list tests to load                                                                                                          |
| grep                  | A regular expressions, which filters the tests to execute                                                                                   |
| timeout               | default global timeout of test executions, defaults to 5000msec                                                                             |
| reporter              | the reporter to use, defaults to 'html'. Use 'tap' for puppeteer test execution, see <https://mochajs.org/#reporters>                       |
| reportOnEnd           | Flag for the 'html' reporter. Use reportOnEnd=false, to enable appending the test reports during test execution (note: reduces performance) |
| registerInternAdapter | Flag to register an amd module which mocks 'intern!object' and 'intern/chai!assert' imports and converts intern tests into mocha bdd tests  |

## Pre-Requisites

The 'mapapps-mocha-runner' requires the packages 'mocha' and 'chai' to work correctly.
Both packages must be available in one of the js-registries.

The packages are normally made available inside a project using the `packages.json`:

```json
"devDependencies": {
        ...
        "@conterra/mapapps-mocha-runner": "^1.0.2",
        "chai": "^4.3.4",
        "mocha": "^10.0.0"
        ...
}
```

Additionally, the js-registry needs to be configured to serve these packages.
This part depends on the registry implementation used and can be configured.
If the java (embedded) js-registry (since 1.4.3) is used, there are two properties, which allow the scanning of the 'node_modules' folder for dev dependencies:

```properties
jsregistry.directoryscanner.npmfolder=${basedir}/node_modules
jsregistry.directoryscanner.npmincludes=mocha,chai,@conterra,@conterra/mapapps-mocha-runner
```

If the `browser-sync` js-registry is used, then in the `gulpfile.js` the packages needs to be listed:

```js
mapappsBrowserSync.registerTask(
    {
        port: 8080,
        jsreg: {
            npmModules: ["mocha", "chai", "@conterra/mapapps-mocha-runner"]
        }
    },
    gulp
);
```

## Configuration

A `test-init.js` is responsible to configure the AMD loader, and e.g. define which js-registries should be requested for packages.
It may look like:

```js
testConfig({
    // (optional) load apprt-polyfill before all tests start
    deps: ["apprt-polyfill"],
    // (optional) which js registry should be requested for packages
    // if left out the default registry and and all packages within the registry are registered
    jsregistry: [
        {
            // (optional) if left out the default registry is used
            root: "url to registry..",
            // packages: ["*"] means all packages of the registry
            packages: [
                // list of packages registered from this registry
                "app-uitest-support",
                "test-utils",
                "uitest",
                "apprt",
                "apprt-core"
            ]
        }
    ],
    // (optional) register custom manual packages
    packages: [
        {
            name: "test-apps",
            location: "@@application.base.url@@/js/tests/test-apps"
        }
    ]
});
```

---
_Source: https://npm.io/package/@conterra/mapapps-mocha-runner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
