1. testee-client
Testee testing framework client adapters
testee-client
Package: testee-client
Created by: bitovi
Last modified: Mon, 27 Jun 2022 05:25:59 GMT
Version: 0.5.6
License: MIT
Downloads: 1,022
Repository: https://github.com/bitovi/testee-client

Install

npm install testee-client
yarn add testee-client

Testee client adapters

Build Status

Testee client side adapters for Mocha, QUnit and Jasmine (1 and 2) that convert test results into Feathers service calls (runs, suites, tests and coverages).

Initializing options

In your test page you can set Testee options using window.Testee.

BaseURL

By default, the client will use the url the tests are running at (window.location.protocol + '//' + window.location.host). you can change this using the baseURL option:

 <script type="text/javascript">
window.Testee = {
  baseURL: 'http://testee-server.com/'
}
</script>
<script type="text/javascript" src="testee-client.js"></script>

Provider

By default, the client will use socket.io to make Feathers service calls. You can change this to use REST by specifying the provider option:

 <script type="text/javascript">
window.Testee = {
  provider: {
    type: 'rest'
  }
}
</script>
<script type="text/javascript" src="testee-client.js"></script>

Socket

You can provide your own socket instance to make Feathers service calls using the socket option:

 <script type="text/javascript" src="http://testee-server.com/socket.io/socket.io.js"></script>
<script type="text/javascript">
window.Testee = {
  socket: io('http://testee-server.com/')
}
</script>
<script type="text/javascript" src="testee-client.js"></script>

Asynchronous Loading

When loading files asynchronously, you need to stop your testing framework from running until all test files are loaded. Then call window.Testee.init(). If you're using steal, you can use the steal-mocha, steal-qunit or steal-jasmine libraries.

Mocha

 <script type="text/javascript" src="//best/cdn/ever/mocha/mocha.js"></script>
<script type="text/javascript" src="testee-client.js"></script>
<script type="text/javascript">
define(['tests.js'], function() {
  if(window.Testee) {
    window.Testee.init();
  }
  mocha.run();
});
</script>

QUnit

 <script type="text/javascript" src="//best/cdn/ever/qunit.js"></script>
<script type="text/javascript" src="testee-client.js"></script>
<script type="text/javascript">
QUnit.config.autorun = false;
define(['tests.js'], function() {
  if(window.Testee) {
    window.Testee.init();
  }
  QUnit.load();
});
</script>

Jasmine

 <script type="text/javascript" src="//best/cdn/ever/jasmine/jasmine.js"></script>
<script type="text/javascript" src="//best/cdn/ever/jasmine/jasmine-html.js"></script>
<script type="text/javascript" src="//best/cdn/ever/jasmine/boot.js"></script>
<script type="text/javascript" src="testee-client.js"></script>
<script type="text/javascript">
define(['tests.js'], function() {
  if(window.Testee) {
    window.Testee.init();
  }
  window.onload();
});
</script>

A test flow:

 var ids = {
  run: guid(),
  suite: guid(),
  childsuite: guid(),
  testpass: guid(),
  testfail: guid()
};

Testee.start({
  id: ids.run,
  environment : navigator.userAgent,
  runner : 'Jasmine'
});

Testee.suite({
  "title": "Main test suite title",
  "root": true, // If it is the root level test suite
  "id": ids.suite,
  "parent": runId
});

Testee.suite({
  "title": "Child test suite",
  "parent": ids.suite,
  "id": ids.childsuite
});

Testee.test({
  "title": "The test title",
  "parent": ids.childsuite, // Parent suite id
  "id": ids.testpass
});

Testee.pass({
  "duration": 0,
  "id": ids.testpass
});

Testee.testEnd({
  "id": ids.testspass
});

Testee.test({
  "title": "A failing test",
  "parent": ids.childsuite,
  "id": ids.testfail
});

Testee.fail({
  "id": ids.testfail,
  "err": {
    "message": "expected 1 to equal 2",
    "stack": "Error: expected 1 to equal 2\n    at Assertion.assert (/Users/daff/Development/node/swarmling/node_modules/expect.js/expect.js:99:13)\n    CUSTOM STACK TRACE"
  }
});

Testee.testEnd({
  "id": ids.testfail
});

Testee.suiteEnd({
  "id": ids.childsuite
});

Testee.suiteEnd({
  "id": ids.suite
});

Testee.end({});

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code