npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@conterra/mapapps-mocha-runner

v1.1.1

Published

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

Downloads

634

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 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:

"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:

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:

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:

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"
        }
    ]
});