Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const suman = require('suman');
const Test = suman.init(module, {});
Test.describe('root suite description', {}, function () { // we define the root suite
//note: we are in the context of the "root suite"
const self = this; // (avoid the self pattern in Suman tests, here for explanation only :)
this.before(function * () {
const bnans = yield new Promise(function (resolve) {
resolve('bananas')
});
console.log('bananas:', bnans);
console.log('1', this === self); //true
});
this.beforeEach(function * () {
#!/usr/bin/env node
'use strict';
const suman = require('suman');
const Test = suman.init(module, {});
Test.create('root suite description', {}, function () { // we define the root suite
//note: we are in the context of the "root suite"
const self = this; // (avoid the self pattern in Suman tests, here for explanation only :)
this.before('aeageo', async function () {
const bnans = await new Promise(function (resolve) {
resolve('bananas')
});
console.log('bananas:', bnans);
console.log('1', this === self); //true
});
#!/usr/bin/env node
'use strict';
const suman = require('suman');
const Test = suman.init(module, {
$inject: ['abc']
});
Test.create(['parallel: true', (b, assert, before, beforeEach, it, after, describe) => {
console.log('arguments => ', arguments);
before(['fatal:false', t => {
// throw new Error('hook');
}]);
before(t => {
console.log('before a');
});
beforeEach.cb({}, t => {
'use strict';
var suman = require('suman');
var Test = suman.init(module, {
timeout: 10000,
integrants: [ 'smartconnect', 'dolce-vida', 'charlie' ]
});
// (suite 2 below has error in hook)
Test.describe('suite 1', { parallel: true }, function () {
this.before.cb('D', t => {
t.done();
});
const cars = [ 1, 2, 3 ];
this.describe('x', function () {
/**
* Created by denman on 3/26/2016.
*/
const suman = require('suman');
const Test = suman.init(module, {
interface: 'BDD' //BDD interface is default but we are explicit
});
// here we create the test suite, we can pass in core modules, and any value defined in suman.ioc.js
Test.create('#Test1', function (assert, fs, http, path, describe, it, beforeEach) {
describe('tests multiplication', function () {
beforeEach(t => { //this runs before any test case inside this describe block
t.data.foo = 3;
});
it('[test] 1', async (t) => { // t represents this test case, t.data properties can be set prior in hooks
const bar = await new Promise(function (resolve) {
resolve('7');
import * as suman from 'suman'; //es6 import syntax
const Test = suman.init(module, {
interface: 'BDD', //BDD interface is default but we are explicit
iocData: makeIOCData()
});
function makeIOCData() {
}
// here we create the test suite, we can pass in core modules, and any value defined in suman.ioc.js
Test.describe('#Test1', function (assert, fs, http, path) {
this.describe('tests multiplication', function () {
this.beforeEach(t => { //this runs before any test case inside this describe block
t.data.foo = 3;
});
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var suman = require('suman');
var Test = suman.init(module, {});
Test.create('root suite description', {}, function () {
// we define the root suite
//note: we are in the context of the "root suite"
var self = this; // (avoid the self pattern in Suman tests, here for explanation only :)
this.before('aeageo', (0, _asyncToGenerator3.default)(_regenerator2.default.mark(function _callee() {
var bnans;
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return new _promise2.default(function (resolve) {
'use strict';
const suman = require('suman');
const Test = suman.init(module, {
override: {
opts: {
allowSkip: true
}
}
});
Test.create(function (b,it, before, beforeEach, describe, context, after) {
// beforeEach.cb(h => {
// return Promise.delay(2000);
// });
it.Cb('should pass');
#!/usr/bin/env node
'use strict';
const suman = require('suman');
const {Test} = suman.init(module);
//////////////////////////////////////////////////////////////////////////
Test.create(['semver', function (b, assert, describe, before, beforeEach, after, afterEach, it) {
const semver = b.ioc.semver; // semver
console.log('semver => ', semver);
before('adds foo', h => {
return Promise.resolve('foo').then(function (v) {
h.assert(v === 'foo');
h.$inject.bar = v;
});
cb();
},
end: function (data) {
console.log('end was called with data=', data);
}
});
writable.on('finish', function () {
writable.finished = true;
});
const Test = suman.init(module, {
export: true,
interface: 'TDD',
writable: writable
});
Test.suite('@Test1', {parallel: false, bail: true}, function (assert, fs, path, stream, extra) {
tests.forEach(test=> {
this.test('tests data', function () {
test(assert);
});