Testee Client Adapters

0.5.6 · maintenance · verified Tue Apr 21

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.

Common errors

Warnings

Install

Imports

Quickstart

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.

<!-- index.html -->
<!DOCTYPE html>
<html>
<head>
  <title>Testee Client Quickstart</title>
  <link rel="stylesheet" href="//cdn.jsdelivr.net/npm/mocha@10.0.0/mocha.min.css">
  <script src="//cdn.jsdelivr.net/npm/mocha@10.0.0/mocha.min.js"></script>
  <script type="text/javascript">
    // Configure Testee client options before loading the script
    window.Testee = {
      baseURL: 'http://localhost:3030/testee-runner', // Replace with your Testee server URL
      provider: { type: 'socket.io' } // Explicitly set for clarity, socket.io is often default
    };
    mocha.setup('bdd');
  </script>
  <!-- Load testee-client AFTER configuration -->
  <script type="text/javascript" src="node_modules/testee-client/dist/testee-client.js"></script>
</head>
<body>
  <div id="mocha"></div>
  <script>
    // Simulate asynchronous test loading and then run tests
    // In a real application, 'tests.js' would contain your actual Mocha tests.
    // Here, we're embedding a simple test.
    Promise.resolve().then(() => {
      describe('My application', () => {
        it('should perform addition correctly', () => {
          // Example of manual Testee API calls (normally handled by adapters)
          if (typeof Testee !== 'undefined' && Testee.start) {
              const runId = 'qs-run-id';
              const suiteId = 'qs-suite-id';
              const testId = 'qs-test-id';

              Testee.start({ id: runId, environment: navigator.userAgent, runner: 'Mocha', framework: 'mocha' });
              Testee.suite({ id: suiteId, title: 'Quickstart Arithmetic Suite', root: true, parent: runId });
              Testee.test({ id: testId, title: '1 + 1 equals 2', parent: suiteId });
              // Actual test assertion
              if (1 + 1 === 2) {
                Testee.pass({ id: testId, duration: 2 });
              } else {
                Testee.fail({ id: testId, err: { message: 'Unexpected result' } });
              }
              Testee.testEnd({ id: testId });
          }
          // Using a common assertion library (e.g., Chai) for actual test logic
          // For this example, we'll just check directly.
          if ((1 + 1) !== 2) {
              throw new Error('1 + 1 should equal 2');
          }
        });
      });

      // After all test files are 'loaded', initialize Testee and run the framework
      if (window.Testee) {
        window.Testee.init();
      }
      mocha.run();
    });
  </script>
</body>
</html>

view raw JSON →