{"id":15856,"library":"testee-client","title":"Testee Client Adapters","description":"testee-client is a client-side library providing adapters for popular JavaScript testing frameworks such as Mocha, QUnit (versions 1 and 2), and Jasmine (versions 1 and 2). It functions by converting test results from these frameworks into Feathers service calls for `runs`, `suites`, `tests`, and `coverages`, which are then reported to a `testee` runner server. The current stable version is 0.5.6. The package appears to be in a maintenance phase, with releases addressing specific environment conflicts or improving existing integrations rather than introducing major new features. Its primary role is to bridge the gap between in-browser test execution and a centralized reporting server, allowing for custom configuration of the base URL, communication provider (sockets or REST), and even custom socket instances. It requires manual initialization (`window.Testee.init()`) in environments where test files are loaded asynchronously to prevent test runners from executing prematurely.","status":"maintenance","version":"0.5.6","language":"javascript","source_language":"en","source_url":"https://github.com/bitovi/testee-client","tags":["javascript","testing","qunit","mocha","jasmine","testee"],"install":[{"cmd":"npm install testee-client","lang":"bash","label":"npm"},{"cmd":"yarn add testee-client","lang":"bash","label":"yarn"},{"cmd":"pnpm add testee-client","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The library is primarily consumed as a global `window.Testee` object after being loaded via a <script> tag in a browser environment. Direct ESM/CJS imports are not the intended usage for its client-side functionality.","wrong":"import { Testee } from 'testee-client'","symbol":"Testee","correct":"<!-- In HTML: -->\n<script type=\"text/javascript\" src=\"testee-client.js\"></script>\n<script type=\"text/javascript\">\n  window.Testee = { baseURL: 'http://testee-server.com/' };\n</script>"},{"note":"This method is called to initialize the client adapters, especially crucial when test files are loaded asynchronously to prevent test frameworks from running prematurely. Ensure `window.Testee` exists before calling.","wrong":"Testee.init() // Called before testee-client.js is loaded or if Testee is not on window","symbol":"Testee.init","correct":"<!-- After asynchronous test files are loaded and Testee is configured: -->\n<script type=\"text/javascript\">\n  if (window.Testee) {\n    window.Testee.init();\n  }\n</script>"},{"note":"Direct API calls like `Testee.start`, `Testee.suite`, `Testee.pass`, and `Testee.fail` are exposed globally for manual test flow reporting. These are typically used internally by framework adapters or for implementing custom test runners, and require `testee-client.js` to be loaded.","wrong":"const { start } = require('testee-client'); start(...)","symbol":"Testee.start","correct":"Testee.start({\n  id: 'some-unique-run-id',\n  environment: navigator.userAgent,\n  runner: 'Mocha',\n  framework: 'mocha'\n});"}],"quickstart":{"code":"<!-- index.html -->\n<!DOCTYPE html>\n<html>\n<head>\n  <title>Testee Client Quickstart</title>\n  <link rel=\"stylesheet\" href=\"//cdn.jsdelivr.net/npm/mocha@10.0.0/mocha.min.css\">\n  <script src=\"//cdn.jsdelivr.net/npm/mocha@10.0.0/mocha.min.js\"></script>\n  <script type=\"text/javascript\">\n    // Configure Testee client options before loading the script\n    window.Testee = {\n      baseURL: 'http://localhost:3030/testee-runner', // Replace with your Testee server URL\n      provider: { type: 'socket.io' } // Explicitly set for clarity, socket.io is often default\n    };\n    mocha.setup('bdd');\n  </script>\n  <!-- Load testee-client AFTER configuration -->\n  <script type=\"text/javascript\" src=\"node_modules/testee-client/dist/testee-client.js\"></script>\n</head>\n<body>\n  <div id=\"mocha\"></div>\n  <script>\n    // Simulate asynchronous test loading and then run tests\n    // In a real application, 'tests.js' would contain your actual Mocha tests.\n    // Here, we're embedding a simple test.\n    Promise.resolve().then(() => {\n      describe('My application', () => {\n        it('should perform addition correctly', () => {\n          // Example of manual Testee API calls (normally handled by adapters)\n          if (typeof Testee !== 'undefined' && Testee.start) {\n              const runId = 'qs-run-id';\n              const suiteId = 'qs-suite-id';\n              const testId = 'qs-test-id';\n\n              Testee.start({ id: runId, environment: navigator.userAgent, runner: 'Mocha', framework: 'mocha' });\n              Testee.suite({ id: suiteId, title: 'Quickstart Arithmetic Suite', root: true, parent: runId });\n              Testee.test({ id: testId, title: '1 + 1 equals 2', parent: suiteId });\n              // Actual test assertion\n              if (1 + 1 === 2) {\n                Testee.pass({ id: testId, duration: 2 });\n              } else {\n                Testee.fail({ id: testId, err: { message: 'Unexpected result' } });\n              }\n              Testee.testEnd({ id: testId });\n          }\n          // Using a common assertion library (e.g., Chai) for actual test logic\n          // For this example, we'll just check directly.\n          if ((1 + 1) !== 2) {\n              throw new Error('1 + 1 should equal 2');\n          }\n        });\n      });\n\n      // After all test files are 'loaded', initialize Testee and run the framework\n      if (window.Testee) {\n        window.Testee.init();\n      }\n      mocha.run();\n    });\n  </script>\n</body>\n</html>","lang":"javascript","description":"This quickstart demonstrates how to include `testee-client.js` in an HTML page, configure `window.Testee` options, and manually initialize it within a Mocha test setup that simulates asynchronous test loading. It includes basic manual reporting via the `Testee` API."},"warnings":[{"fix":"Upgrade to `testee-client@0.5.3` or a later version to ensure all necessary distribution files are present.","message":"Version 0.5.2 was a faulty release distributed without the required `dist/` folder, rendering the package unusable if installed. Users attempting to use this specific version will encounter file not found errors.","severity":"breaking","affected_versions":"=0.5.2"},{"fix":"Upgrade to `testee-client@0.5.6` which includes a rebuilt distribution specifically addressing and resolving this conflicting `steal-tools` process shim.","message":"In version 0.5.6, a conflict was identified where `steal-tools`'s process shim could inadvertently override `testee-client`'s intended process shim. This led to incorrect `process.cwd()` results (e.g., returning an empty string instead of `/`) in certain build environments, specifically affecting projects using StealJS.","severity":"gotcha","affected_versions":"<=0.5.5"},{"fix":"For QUnit, set `QUnit.config.autorun = false;`. For other frameworks, ensure the framework's `run` method is called only after your test files are ready and `window.Testee.init()` has been explicitly invoked. Refer to framework-specific asynchronous loading examples in the documentation.","message":"When integrating `testee-client` with test frameworks that load test files asynchronously (e.g., using `define` with RequireJS or StealJS), it is critical to prevent the test framework from running automatically. `window.Testee.init()` must then be called manually *after* all test files are loaded and before the framework's `run` method is invoked.","severity":"gotcha","affected_versions":">=0.0.1"}],"env_vars":null,"last_verified":"2026-04-21T00:00:00.000Z","next_check":"2026-07-20T00:00:00.000Z","problems":[{"fix":"Ensure you are using `testee-client@0.5.3` or a later version, as version 0.5.2 was a faulty release and is missing critical files.","cause":"This error most commonly occurs when attempting to use `testee-client@0.5.2`, which was released without the necessary distribution files in its `dist/` folder, making the package effectively unusable.","error":"Error: Cannot find module 'testee-client/dist/testee-client.js' (or similar file not found errors for dist/ files)"},{"fix":"Upgrade `testee-client` to version 0.5.6 or higher. This version includes a fix that rebuilds the distribution without the conflicting `steal-tools` process shim.","cause":"A specific conflict between the `steal-tools` process shim and `testee-client`'s internal shim in versions prior to 0.5.6 caused `process.cwd()` to return an incorrect or empty value, affecting tests relying on it.","error":"process.cwd() returns an empty string or an unexpected path in StealJS/steal-tools environments"},{"fix":"Ensure that the `<script src=\"path/to/testee-client.js\"></script>` tag is correctly placed in your HTML and executed before any code that attempts to access `window.Testee` or call `window.Testee.init()`.","cause":"The `testee-client.js` script was not loaded in the browser, or `window.Testee` was accessed before the script had fully executed and populated the global object.","error":"Uncaught ReferenceError: Testee is not defined"}],"ecosystem":"npm"}