JSFiddle - React, Tailwind, and code Playground

by Daniel Lizik

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/chai/3.5.0/chai.js"></script>

JavaScript

(function(env, globals, setup) {
  var fns = globals()
  if (env.module) {
    if (typeof env.module.exports === 'object')
      return setup(module, fns);
  }
  else
    return setup(env, fns);
})(this, function() {

  var suites = [];

  function describe(desc, callback) {
    suites.push({suite: desc, specs: []});
    callback();
  }
  
  function it(should, callback) {
    var curr = suites[suites.length - 1];
    try {
      callback();
    }
    catch(e) {
      e.should = should;
      curr.specs.push(e);
      return;
    }
    curr.specs.push({should: should});
  }
  
  return {
    describe: describe,
    it: it,
    $$suites: suites
  };

}, function(env, globals) {
  for (var p in globals)
    env[p] = globals[p];
});

describe('something', function() {
  it('should 1 === 1', function() {
 	  chai.assert.equal(34, 34);
    chai.assert.equal(true, false);
  });
});

describe('another suite', function() {
	it('should be falsy', function() {
  	chai.assert.deepEqual({a: 1}, {a: 1});
  })
})

$$suites.forEach(function(s) {
  console.log(s.suite.toUpperCase())
  s.specs.forEach(sp => console.log(sp))
})