Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone test/assertion library #32

Open
rtsao opened this issue Dec 9, 2017 · 0 comments
Open

Standalone test/assertion library #32

rtsao opened this issue Dec 9, 2017 · 0 comments
Milestone

Comments

@rtsao
Copy link
Owner

rtsao commented Dec 9, 2017

The goals of TAP and tape are great, but an alternative would be nice for a number of reasons:

  1. TAP is difficult to work with
    • Bad experience for humans out of the box
    • TAP formatters don't work that well, especially when regular stdout and tests are mixed
  2. tape requires a bunch of Node.js built-ins (fs, Buffer, process)
    • Bundling these for a browser test environment is simply unacceptable
  3. Tape is generally more bloated and complex than needed.
  4. The tape interface is not oriented around async/await

A replacement should be implemented while preserving the following desirable qualities from tape:

  1. Not require any special test runner (i.e. running tests directly via Node.js should work fine)
  2. Works fine in Node.js and browsers
  3. Optional, nice machine-readable test output.

Fortunately, the Chrome Remote debug protocol provides a mechanism to imperatively trigger a different logging mechanism for when a test runner wants to do fancier output.

API example

import test from 'unitest';

/**
 * Synchronous tests (always executed serially)
 */
test('sync1', t => {
  t.pass('dummy');
});
test('sync2', t => {
  t.pass('dummy');
});
test('sync3', t => {
  t.pass('dummy');
});

/**
 * Async tests (concurrent execution by default)
 */
test('async1', async t => {
  await something();
  t.pass('dummy');
});
test('async2', async t => {
  await something();
  t.pass('dummy');
});
test('async3', async t => {
  await something();
  t.pass('dummy');
});

/**
 * Async tests (forced serial execution)
 */
test.serial('async1 (serial)', async t => {
  await something();
  t.pass('dummy');
});
test.serial('async2 (serial)', async t => {
  await something();
  t.pass('dummy');
});
test.serial('async3 (serial)', async t => {
  await something();
  t.pass('dummy');
});
@rtsao rtsao added this to the 3.x milestone Dec 9, 2017
@rtsao rtsao mentioned this issue Dec 9, 2017
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant