{"id":15023912,"url":"https://github.com/sap/karma-ui5","last_synced_at":"2025-05-16T08:04:39.413Z","repository":{"id":23756136,"uuid":"27130443","full_name":"SAP/karma-ui5","owner":"SAP","description":"A Karma plugin for UI5","archived":false,"fork":false,"pushed_at":"2025-03-29T04:39:37.000Z","size":6299,"stargazers_count":70,"open_issues_count":9,"forks_count":26,"subscribers_count":20,"default_branch":"main","last_synced_at":"2025-05-15T13:55:01.544Z","etag":null,"topics":["open-source"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SAP.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2014-11-25T14:51:58.000Z","updated_at":"2025-04-04T03:38:37.000Z","dependencies_parsed_at":"2024-02-04T04:25:02.251Z","dependency_job_id":"614b9d70-b35f-459c-94a8-b876d42ba2a9","html_url":"https://github.com/SAP/karma-ui5","commit_stats":{"total_commits":580,"total_committers":25,"mean_commits":23.2,"dds":0.6103448275862069,"last_synced_commit":"aea49acdf8ecfafa6c73b397a8aaa22597b2d51d"},"previous_names":["sap/karma-openui5"],"tags_count":32,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fkarma-ui5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fkarma-ui5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fkarma-ui5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SAP%2Fkarma-ui5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SAP","download_url":"https://codeload.github.com/SAP/karma-ui5/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254493378,"owners_count":22080126,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["open-source"],"created_at":"2024-09-24T19:59:36.168Z","updated_at":"2025-05-16T08:04:38.343Z","avatar_url":"https://github.com/SAP.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/main/docs/images/UI5_logo_wide.png)\n\n[![REUSE status](https://api.reuse.software/badge/github.com/SAP/karma-ui5)](https://api.reuse.software/info/github.com/SAP/karma-ui5)\n[![NPM Version](https://img.shields.io/npm/v/karma-ui5.svg?style=flat)](https://www.npmjs.org/package/karma-ui5)\n\n# DEPRECATED\n**⚠️ This project has been deprecated. We recommend you to pick a successor from the [available UI5 community projects](https://bestofui5.org/#/packages?tokens=testing:tag). For more information see [Deprecation of karma-ui5 plugin](https://community.sap.com/t5/technology-blogs-by-sap/deprecation-of-karma-ui5-plugin/ba-p/13954060)**\n\n**Table of Contents**\n- [About](#about)\n- [Quickstart](#quickstart)\n\t- [Installation](#installation)\n\t- [Configuration](#configuration)\n\t\t- [Script Mode](#script-mode)\n\t- [Execution](#execution)\n- [Karma Configuration Requirements](#karma-configuration-requirements)\n- [Options](#options)\n\t- [url](#url)\n\t- [type](#type)\n\t- [paths](#paths)\n\t- [configPath](#configpath)\n\t- [mode](#mode)\n\t\t- [html](#html)\n\t\t- [script](#script)\n\t- [testpage](#testpage)\n\t- [urlParameters](#urlparameters)\n\t- [failOnEmptyTestPage](#failonemptytestpage)\n\t- [config](#config)\n\t- [tests](#tests)\n\t- [fileExport](#fileexport)\n- [API](#api)\n\t- [helper](#helper)\n\t\t- [configureIframeCoverage](#configureiframecoverage)\n- [Notes on UI5 Tooling Custom Server Middleware](#notes-on-ui5-tooling-custom-server-middleware)\n- [License](#license)\n\n\n## About\nThis Karma plugin helps testing your UI5 projects.\n\nPlease refer to the [Testing](https://openui5.hana.ondemand.com/#/topic/7cdee404cac441888539ed7bfe076e57) section in the UI5 Developer Guide for information about writing tests for your project.\n\n**Note:** This project has been renamed from `karma-openui5` to `karma-ui5` with the v1.0.0 release.  \nFor upgrade information, see the [Migration Guide](./docs/migrate-v1.md).  \nFor the `karma-openui5` documentation, see [0.x branch](https://github.com/SAP/karma-ui5/tree/0.x#readme).\n\n\n## Quickstart\n\n### Installation\n\nFirst you need to install the Karma CLI globally:\n\n```shell\nnpm install -g karma-cli\n```\n\nYou can find more information on installing Karma [here](https://karma-runner.github.io/latest/intro/installation.html).\n\nNext, you need to add `karma` and `karma-ui5` as devDependencies:\n\n```shell\nnpm install --save-dev karma karma-ui5\n```\n\nTo start a browser, you also need to install a launcher, e.g. for Chrome:\n\n```shell\nnpm install --save-dev karma-chrome-launcher\n```\n\n### Configuration\n\nTo configure the plugin, you need to add two things to your `karma.conf.js`:\n1. Specify `\"ui5\"` in the list of `frameworks`.\n1. Set a URL for serving the UI5 resources.\n   - **Note:** This can be omitted when you use [UI5 Tooling](#url).\n\nThis is an example `karma.conf.js` file that is sufficient for most projects:\n\n```js\nmodule.exports = function(config) {\n  config.set({\n\n    frameworks: [\"ui5\"],\n\n    ui5: {\n      url: \"https://openui5.hana.ondemand.com\"\n    },\n\n    browsers: [\"Chrome\"]\n\n  });\n};\n```\n\n#### Script Mode\n\n*(Optional, next step: [Execution](#execution))*\n\nThe configuration above implies to use the [`html` mode](#html), which is recommended.\nIt runs your existing test pages and does not require additional Karma plugins or configuration.\n\nHowever the [`script` mode](#script) is more flexible and better allows integration with other karma plugins / frameworks.\n\nThe following steps describe a minimal configuration for the `script` mode.\n\nWith the `script` mode you need to also include a testing framework and its Karma adapter, like [QUnit](https://qunitjs.com/) and [karma-qunit](https://github.com/karma-runner/karma-qunit).\n```shell\nnpm install --save-dev qunit karma-qunit\n```\n\nTo use test spies, stubs and mocks you need to install [Sinon.JS](https://sinonjs.org/) and [karma-sinon](https://github.com/yanoosh/karma-sinon).\n```shell\nnpm install --save-dev sinon karma-sinon\n```\n\nBoth frameworks need to be added to the `karma.conf.js`.  \nNote that `ui5` should be the first entry.\n```js\nframeworks: [\"ui5\", \"qunit\", \"sinon\"]\n```\n\nNext, you need to provide the UI5 bootstrap configuration (see [config](#config)).  \nThe `resourceRoots` configuration should be aligned with your project namespace.\n```js\nui5: {\n  config: {\n    async: true,\n    resourceRoots: {\n      \"sap.ui.demo.todo\": \"./base/webapp\"\n    }\n  }\n}\n```\n\nLast but not least the test modules need to be listed, so that they are executed.\n```js\nui5: {\n  tests: [\n    \"sap/ui/demo/todo/test/unit/AllTests\"\n  ]\n}\n```\n\nHere is the full example for the `script` mode:\n```js\nmodule.exports = function(config) {\n  config.set({\n    frameworks: [\"ui5\", \"qunit\", \"sinon\"],\n    ui5: {\n      url: \"https://openui5.hana.ondemand.com\",\n      mode: \"script\",\n      config: {\n        async: true,\n        resourceRoots: {\n          \"sap.ui.demo.todo\": \"./base/webapp\"\n        }\n      },\n      tests: [\n        \"sap/ui/demo/todo/test/unit/AllTests\"\n      ]\n    },\n    browsers: [\"Chrome\"]\n  });\n};\n```\n\n### Execution\n\nWith the above configuration, karma will by default run all tests in Chrome and listen for changed files to execute them again (watch mode).\n\n```sh\nkarma start\n```\n\nFor CI testing, you can run Chrome in headless mode and execute the tests only once using the `singleRun` option:\n\n```js\nmodule.exports = function(config) {\n  config.set({\n\n    // ...\n\n    browsers: [\"ChromeHeadless\"],\n    singleRun: true\n\n  });\n};\n```\n\nThe options can also be set via CLI arguments:\n\n```sh\nkarma start --browsers=ChromeHeadless --singleRun=true\n```\n\nFor more information, see the [\"Configuration File\" documentation from Karma](https://karma-runner.github.io/latest/config/configuration-file.html).\n\n## Karma Configuration Requirements\n\nThere is an important requirement for using this plugin:\n\n- The karma `basePath` option **must point to your project root, not to a subfolder** like \"webapp\". This is the default when your `karma.conf.js` is in the project root.  \nIt is required for the [type detection](#type) and automatic inclusion of your project files.\n\n## Options\n\nAll configuration options need to be defined in an `ui5` object in your Karma configuration:\n\n```js\nmodule.exports = function(config) {\n  config.set({\n\n    ui5: {\n\n    }\n\n  });\n};\n```\n\n### url\nType: `string`  \nCLI: `--ui5.url`\n\nThe URL where UI5 should be loaded from.\n\nWhen omitted and the project contains a `ui5.yaml` file, [UI5 Tooling](https://github.com/SAP/ui5-tooling) will be used as server middleware. Beware of restrictions outlined in [Notes on UI5 Tooling Custom Server Middleware](#notes-on-ui5-tooling-custom-server-middleware).\n\nExample:\n```js\nui5: {\n  url: \"https://openui5.hana.ondemand.com\"\n}\n```\n\n### type\nType: `enum` (`\"application\"` / `\"library\"`)  \n\nDefines the [project type](https://github.com/SAP/ui5-builder#types).  \nIf not set, it is automatically detected based on\n- the type defined in `ui5.yaml`, or\n- existing folders\n  - \"webapp\" =\u003e `application`\n  - \"src\" / \"test\" =\u003e `library`\n\nExample:\n\n```js\nui5: {\n  type: \"application\"\n}\n```\n\n### paths\nType: `object`\n\nCustom path mappings for project folders based on the `type`.  \nUse this option only when the automatic type detection does not work because the project uses a different folder structure.\n\nExample `application`:\n```js\nui5: {\n  type: \"application\",\n  paths: {\n    webapp: \"src/main/webapp\"\n  }\n}\n```\n\nExample `library`:\n```js\nui5: {\n  type: \"library\",\n  paths: {\n    src: \"src/main/js\",\n    test: \"src/test/js\"\n  }\n}\n```\n\n### configPath\nType: `string`  \nDefault: `\"ui5.yaml\"`  \nCLI: `--ui5.configPath`\n\nPath to the UI5 configuration file.\nIt is resolved relative to the project root.\n\nExample:\n```js\nui5: {\n  configPath: \"ui5-test.yaml\"\n}\n```\n\n### mode\nType: `enum` (`\"html\"` / `\"script\"`)  \nDefault: `\"html\"`\n\nConfigures the mode how tests should be executed.\n\n#### html\n\nThe HTML mode runs QUnit test suites and test pages in a separate context.  \nIt has built-in support for QUnit. The [QUnit adapter](https://github.com/karma-runner/karma-qunit) **must not be used** in combination with this mode. Other framework plugins must also **not** be used. Instead, the required libraries such as sinon should be loaded within the test.\n\n```js\nui5: {\n  mode: \"html\"\n}\n```\n\nSpecific config options:\n- [testpage](#testpage)\n- [urlParameters](#urlParameters)\n- [failOnEmptyTestPage](#failonemptytestpage)\n\n#### script\n\nThe script mode includes the UI5 bootstrap script. It allows to pass UI5 config and loads your test modules.  \nYou need to also install and configure an adapter for your test framework such as [QUnit](https://github.com/karma-runner/karma-qunit), to enable test execution and reporting.\n\n```js\nui5: {\n  mode: \"script\"\n}\n```\n\nSpecific config options:\n- [config](#config)\n- [tests](#tests)\n\n### testpage\nType: `string`  \nCLI: `--ui5.testpage`  \nSpecific to [\"html\" mode](#html)\n\nA file path pointing to a test page or test suite that should be executed.  \nThe path needs to be relative to the project root.\n\nIf not set, the project is scanned for available test suites (`testsuite.qunit.html`).  \nWhen exactly one test suite is found, it will be used as `testpage`. Otherwise, all found pages are printed out and one of them needs to be configured manually.\n\nExample:\n```js\nui5: {\n  mode: \"html\",\n  testpage: \"webapp/test/myTestPage.qunit.html\"\n}\n```\n\n### urlParameters\nType: `Array`  \nSpecific to [\"html\" mode](#html)\n\nURL parameters to append to every testpage.\n\nExample:\n```js\nui5: {\n    mode: \"html\",\n    urlParameters: [{\n        key: \"hidepassed\",\n        value: true\n    }]\n}\n```\n\n### failOnEmptyTestPage\nType: `boolean`  \nDefault: `false`  \nCLI: `--ui5.failOnEmptyTestPage`  \nSpecific to [\"html\" mode](#html)\n\nReports an error when a test page does not define any tests.  \nThe [Karma configuration `failOnEmptyTestSuite`](https://karma-runner.github.io/latest/config/configuration-file.html) only covers the case when no tests were defined at all, but not when just one testpage doesn't define tests.\n\nExample:\n```js\nui5: {\n\t\tmode: \"html\",\n\t\tfailOnEmptyTestPage: true\n}\n```\n\n### config\nType: `object`  \nSpecific to [\"script\" mode](#script)\n\nConfiguration of the [UI5 bootstrap](https://openui5.hana.ondemand.com/#/topic/91f2d03b6f4d1014b6dd926db0e91070.html).\n\nExample:\n```js\nui5: {\n  mode: \"script\",\n  config: {\n    bindingSyntax: \"complex\",\n    compatVersion: \"edge\",\n    async: true,\n    resourceRoots: {\n      \"sap.ui.demo.todo\": \"./base/webapp\"\n    }\n  }\n}\n```\n\n### tests\nType: `Array`  \nSpecific to [\"script\" mode](#script)\n\nList of test modules that should be loaded (via `sap.ui.require`).  \nIf not provided, the test files must be included in the [karma `files` config](https://karma-runner.github.io/latest/config/files.html) to load them with \u0026lt;script\u0026gt; tags.\n\nExample:\n```js\nui5: {\n  mode: \"script\",\n  tests: [\n    \"sap/ui/demo/todo/test/unit/AllTests\",\n    \"sap/ui/demo/todo/test/integration/AllJourneys\"\n  ]\n}\n```\n\n### fileExport\nType: `boolean` or `object`  \nDefault: `false`\n\nConfigures whether report files provided by tools like UI5 Support Assistant are exported to the file system.  \nOptionally, an output directory can be set to specify the export path.\n\nExample `boolean`:\n```js\nui5: {\n  fileExport: true\n}\n```\n\nExample `object`:\n```js\nui5: {\n  fileExport: {\n    outputDir: \"directory/to/export/files\"\n  }\n}\n```\n\nProjects can also add report files by themselves by setting or enhancing the global `window._$files` array in the executed source code in the following way:\n```js\nwindow._$files = window._$files || [];\nwindow._$files.push({\n  name: \"file_name.txt\",\n  content: \"file content\"\n});\n```\n\n## API\n\n### helper\n\nThis plugin also comes with a helper module to be used in your Karma configuration file.\n\n#### configureIframeCoverage\n\nEnables code coverage for iframes.\nCan only be used in combination with the [karma-coverage](https://github.com/karma-runner/karma-coverage) plugin (v2.0.0+).\n\nMust be called from the karma configuration function after the coverage plugin has been configured.\nThe `config` object must be passed as a parameter.\n\n```js\nmodule.exports = function(config) {\n\tconfig.set({\n\n\t\t// ...\n\n\t});\n\trequire(\"karma-ui5/helper\").configureIframeCoverage(config);\n};\n```\n\n## Notes on UI5 Tooling Custom Server Middleware\n\nIf the [url](#url)-option is not used, and if the project contains a `ui5.yaml` file, `karma-ui5` will automatically use [UI5 Tooling](https://github.com/SAP/ui5-tooling) to start an internal server. Any custom middleware configured in the `ui5.yaml` will be used automatically.\n\nHowever, since Karma uses the [`connect`](https://github.com/senchalabs/connect) framework, as opposed to UI5 Tooling's [`express`](https://github.com/expressjs/express), custom middleware might not always work as expected. Compared to `connect`, the `express` framework provides a more versatile API to middleware.\n\nTherefore, if you plan to use custom middleware in an integrated scenario with `karma-ui5`, you must **restrict the middleware to using the [`connect`](https://github.com/senchalabs/connect) API only** to ensure compatibility.\n\nAlternatively, you can start a server with the usual `ui5 serve` command and [configure the corresponding URL](#url).\n\nFor more information see [UI5 Tooling - Custom UI5 Server Middleware](https://sap.github.io/ui5-tooling/stable/pages/extensibility/CustomServerMiddleware/).\n\n## Big Thanks\n\nCross-browser Testing Platform and Open Source \u003c3 Provided by [Sauce Labs](https://saucelabs.com).\n\n\u003cimg width=\"200px\" alt=\"Testing Provided by Sauce Labs\" src=\"./resources/saucelabs.svg\"\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fkarma-ui5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsap%2Fkarma-ui5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsap%2Fkarma-ui5/lists"}