Comparing version 2.0.2 to 2.0.3
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -33,6 +25,4 @@ /* | ||
*/ | ||
function asPromise(fn, args) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield fn(...args); | ||
}); | ||
async function asPromise(fn, args) { | ||
return await fn(...args); | ||
} | ||
@@ -39,0 +29,0 @@ /** |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -75,12 +67,10 @@ /* | ||
*/ | ||
_runHook(fn) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield fn.run(); | ||
} | ||
catch (error) { | ||
this._completed = true; | ||
this._error = error; | ||
} | ||
}); | ||
async _runHook(fn) { | ||
try { | ||
await fn.run(); | ||
} | ||
catch (error) { | ||
this._completed = true; | ||
this._error = error; | ||
} | ||
} | ||
@@ -90,49 +80,47 @@ /** | ||
*/ | ||
_runTest(test) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
/** | ||
* Run beforeEach hooks | ||
*/ | ||
for (let hook of this._hooks.beforeEach) { | ||
if (this._completed) { | ||
break; | ||
} | ||
yield this._runHook(hook); | ||
async _runTest(test) { | ||
/** | ||
* Run beforeEach hooks | ||
*/ | ||
for (let hook of this._hooks.beforeEach) { | ||
if (this._completed) { | ||
break; | ||
} | ||
/** | ||
* Return early if completed is set to true (happens when any hook throws error) | ||
*/ | ||
await this._runHook(hook); | ||
} | ||
/** | ||
* Return early if completed is set to true (happens when any hook throws error) | ||
*/ | ||
if (this._completed) { | ||
return; | ||
} | ||
/** | ||
* Otherwise run the test | ||
*/ | ||
await test.run(); | ||
/** | ||
* Setting flag to true when any one test has failed. This helps | ||
* in telling runner to exit process with the correct status. | ||
*/ | ||
const testFailed = test.toJSON().status === Contracts_1.ITestStatus.FAILED; | ||
if (!this._hasFailingTests && testFailed) { | ||
this._hasFailingTests = true; | ||
} | ||
/** | ||
* Mark group as completed when bail is set to true and | ||
* test has failed | ||
*/ | ||
if (this._options.bail && testFailed) { | ||
this._completed = true; | ||
return; | ||
} | ||
/** | ||
* Run all after each hooks | ||
*/ | ||
for (let hook of this._hooks.afterEach) { | ||
if (this._completed) { | ||
return; | ||
break; | ||
} | ||
/** | ||
* Otherwise run the test | ||
*/ | ||
yield test.run(); | ||
/** | ||
* Setting flag to true when any one test has failed. This helps | ||
* in telling runner to exit process with the correct status. | ||
*/ | ||
const testFailed = test.toJSON().status === Contracts_1.ITestStatus.FAILED; | ||
if (!this._hasFailingTests && testFailed) { | ||
this._hasFailingTests = true; | ||
} | ||
/** | ||
* Mark group as completed when bail is set to true and | ||
* test has failed | ||
*/ | ||
if (this._options.bail && testFailed) { | ||
this._completed = true; | ||
return; | ||
} | ||
/** | ||
* Run all after each hooks | ||
*/ | ||
for (let hook of this._hooks.afterEach) { | ||
if (this._completed) { | ||
break; | ||
} | ||
yield this._runHook(hook); | ||
} | ||
}); | ||
await this._runHook(hook); | ||
} | ||
} | ||
@@ -143,19 +131,17 @@ /** | ||
*/ | ||
_runTests() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
/** | ||
* Run all the tests in sequence. If any hook beforeEach or afterEach | ||
* hook fails, it will set `complete = true` and then we break out | ||
* of the loop, since if hooks are failing, then there is no | ||
* point is running tests. | ||
*/ | ||
for (let test of this._tests) { | ||
if (this._completed) { | ||
break; | ||
} | ||
if (!this._options.grep || this._options.grep.test(test.toJSON().title)) { | ||
yield this._runTest(test); | ||
} | ||
async _runTests() { | ||
/** | ||
* Run all the tests in sequence. If any hook beforeEach or afterEach | ||
* hook fails, it will set `complete = true` and then we break out | ||
* of the loop, since if hooks are failing, then there is no | ||
* point is running tests. | ||
*/ | ||
for (let test of this._tests) { | ||
if (this._completed) { | ||
break; | ||
} | ||
}); | ||
if (!this._options.grep || this._options.grep.test(test.toJSON().title)) { | ||
await this._runTest(test); | ||
} | ||
} | ||
} | ||
@@ -249,35 +235,33 @@ /** | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.GROUPSTARTED, this.toJSON()); | ||
/** | ||
* Run all before hooks for the group | ||
*/ | ||
for (let hook of this._hooks.before) { | ||
if (this._completed) { | ||
break; | ||
} | ||
yield this._runHook(hook); | ||
async run() { | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.GROUPSTARTED, this.toJSON()); | ||
/** | ||
* Run all before hooks for the group | ||
*/ | ||
for (let hook of this._hooks.before) { | ||
if (this._completed) { | ||
break; | ||
} | ||
/** | ||
* Run the tests, if complete flag is not set to true. It is | ||
* set to true, when any before hooks fail | ||
*/ | ||
if (!this._completed) { | ||
yield this._runTests(); | ||
await this._runHook(hook); | ||
} | ||
/** | ||
* Run the tests, if complete flag is not set to true. It is | ||
* set to true, when any before hooks fail | ||
*/ | ||
if (!this._completed) { | ||
await this._runTests(); | ||
} | ||
/** | ||
* Run all after hooks | ||
*/ | ||
for (let hook of this._hooks.after) { | ||
if (this._completed) { | ||
break; | ||
} | ||
/** | ||
* Run all after hooks | ||
*/ | ||
for (let hook of this._hooks.after) { | ||
if (this._completed) { | ||
break; | ||
} | ||
yield this._runHook(hook); | ||
} | ||
this._completed = true; | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.GROUPCOMPLETED, this.toJSON()); | ||
}); | ||
await this._runHook(hook); | ||
} | ||
this._completed = true; | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.GROUPCOMPLETED, this.toJSON()); | ||
} | ||
} | ||
exports.Group = Group; |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -37,15 +29,13 @@ /* | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
try { | ||
yield Callable_1.Callable(this._resolveFn, this._fn, 0); | ||
} | ||
catch (error) { | ||
error.lifecycle = this._hookLifecycle; | ||
error.fnName = this._fn.name; | ||
throw error; | ||
} | ||
}); | ||
async run() { | ||
try { | ||
await Callable_1.Callable(this._resolveFn, this._fn, 0); | ||
} | ||
catch (error) { | ||
error.lifecycle = this._hookLifecycle; | ||
error.fnName = this._fn.name; | ||
throw error; | ||
} | ||
} | ||
} | ||
exports.Hook = Hook; |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -51,34 +43,32 @@ /* | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (typeof (this._reporterFn) !== 'function') { | ||
throw new Error('Make sure to define tests reporter as a function'); | ||
} | ||
async run() { | ||
if (typeof (this._reporterFn) !== 'function') { | ||
throw new Error('Make sure to define tests reporter as a function'); | ||
} | ||
/** | ||
* Give emitter instance to the reporter | ||
*/ | ||
this._reporterFn(Emitter_1.emitter, this._options); | ||
/** | ||
* Emit the started event | ||
*/ | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.STARTED); | ||
/** | ||
* Run all the tests | ||
*/ | ||
for (let group of this._groups) { | ||
await group.run(); | ||
/** | ||
* Give emitter instance to the reporter | ||
* Break when bail is true and group has errors | ||
*/ | ||
this._reporterFn(Emitter_1.emitter, this._options); | ||
/** | ||
* Emit the started event | ||
*/ | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.STARTED); | ||
/** | ||
* Run all the tests | ||
*/ | ||
for (let group of this._groups) { | ||
yield group.run(); | ||
/** | ||
* Break when bail is true and group has errors | ||
*/ | ||
if (this._options.bail && group.hasErrors) { | ||
break; | ||
} | ||
if (this._options.bail && group.hasErrors) { | ||
break; | ||
} | ||
/** | ||
* Emit completed event | ||
*/ | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.COMPLETED); | ||
}); | ||
} | ||
/** | ||
* Emit completed event | ||
*/ | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.COMPLETED); | ||
} | ||
} | ||
exports.Runner = Runner; |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -87,29 +79,27 @@ /* | ||
*/ | ||
function run(exitProcess = true) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const runner = new Runner_1.Runner(groups, runnerOptions); | ||
runner.reporter(reporterFn); | ||
const loaderFiles = yield loader.loadFiles(); | ||
if (loaderFiles.length && groups.length) { | ||
console.log(chalk_1.default.bgRed('Calling configure inside test file is not allowed. Create a master file for same')); | ||
async function run(exitProcess = true) { | ||
const runner = new Runner_1.Runner(groups, runnerOptions); | ||
runner.reporter(reporterFn); | ||
const loaderFiles = await loader.loadFiles(); | ||
if (loaderFiles.length && groups.length) { | ||
console.log(chalk_1.default.bgRed('Calling configure inside test file is not allowed. Create a master file for same')); | ||
process.exit(1); | ||
} | ||
/** | ||
* Load all files from the loader | ||
*/ | ||
loaderFiles.forEach((file) => require(file)); | ||
try { | ||
await runner.run(); | ||
if (exitProcess) { | ||
process.exit(0); | ||
} | ||
} | ||
catch (error) { | ||
if (exitProcess) { | ||
process.exit(1); | ||
} | ||
/** | ||
* Load all files from the loader | ||
*/ | ||
loaderFiles.forEach((file) => require(file)); | ||
try { | ||
yield runner.run(); | ||
if (exitProcess) { | ||
process.exit(0); | ||
} | ||
} | ||
catch (error) { | ||
if (exitProcess) { | ||
process.exit(1); | ||
} | ||
} | ||
groups = []; | ||
activeGroup = null; | ||
}); | ||
} | ||
groups = []; | ||
activeGroup = null; | ||
} | ||
@@ -116,0 +106,0 @@ exports.run = run; |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -45,22 +37,20 @@ /* | ||
*/ | ||
loadFiles() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if (!this._glob) { | ||
return []; | ||
} | ||
const fg = yield Promise.resolve().then(() => require('fast-glob')); | ||
let filesPaths = yield fg.default(this._glob, { | ||
absolute: true, | ||
onlyFiles: false, | ||
}); | ||
/** | ||
* If filterFn is defined, then filter the files | ||
*/ | ||
if (typeof (this._filterFn) === 'function') { | ||
filesPaths = filesPaths.filter((file) => this._filterFn(file)); | ||
} | ||
return filesPaths.sort(); | ||
async loadFiles() { | ||
if (!this._glob) { | ||
return []; | ||
} | ||
const fg = await Promise.resolve().then(() => require('fast-glob')); | ||
let filesPaths = await fg.default(this._glob, { | ||
absolute: true, | ||
onlyFiles: false, | ||
}); | ||
/** | ||
* If filterFn is defined, then filter the files | ||
*/ | ||
if (typeof (this._filterFn) === 'function') { | ||
filesPaths = filesPaths.filter((file) => this._filterFn(file)); | ||
} | ||
return filesPaths.sort(); | ||
} | ||
} | ||
exports.Loader = Loader; |
@@ -5,10 +5,2 @@ "use strict"; | ||
*/ | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -94,3 +86,3 @@ /* | ||
const op = retry.operation({ retries: this._retries, factor: 1 }); | ||
op.attempt(() => __awaiter(this, void 0, void 0, function* () { | ||
op.attempt(async () => { | ||
Callable_1.Callable(this._resolveFn, this._callback, this._timeout) | ||
@@ -104,3 +96,3 @@ .then(resolve) | ||
}); | ||
})); | ||
}); | ||
}); | ||
@@ -170,33 +162,31 @@ } | ||
*/ | ||
run() { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.TESTSTARTED, this.toJSON()); | ||
const start = timeSpan(); | ||
/* istanbul ignore else */ | ||
if (!this._todo && !this._skip) { | ||
async run() { | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.TESTSTARTED, this.toJSON()); | ||
const start = timeSpan(); | ||
/* istanbul ignore else */ | ||
if (!this._todo && !this._skip) { | ||
/** | ||
* Run the actual test | ||
*/ | ||
try { | ||
await this._runTest(); | ||
/** | ||
* Run the actual test | ||
* Mark test as failed, when is regression but passed | ||
*/ | ||
try { | ||
yield this._runTest(); | ||
/** | ||
* Mark test as failed, when is regression but passed | ||
*/ | ||
if (this._regression) { | ||
throw new Exceptions_1.RegressionException('Expected regression test to fail'); | ||
} | ||
if (this._regression) { | ||
throw new Exceptions_1.RegressionException('Expected regression test to fail'); | ||
} | ||
catch (error) { | ||
this._error = error; | ||
if (!this._isHardException && this._regression) { | ||
this._regressionMessage = error.message; | ||
} | ||
} | ||
catch (error) { | ||
this._error = error; | ||
if (!this._isHardException && this._regression) { | ||
this._regressionMessage = error.message; | ||
} | ||
} | ||
this._duration = start.rounded(); | ||
this._completed = true; | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.TESTCOMPLETED, this.toJSON()); | ||
}); | ||
} | ||
this._duration = start.rounded(); | ||
this._completed = true; | ||
Emitter_1.emitter.emit(Contracts_1.IEvents.TESTCOMPLETED, this.toJSON()); | ||
} | ||
} | ||
exports.Test = Test; |
@@ -0,1 +1,6 @@ | ||
<a name="2.0.3"></a> | ||
## [2.0.3](https://github.com/thetutlage/japa/compare/v2.0.2...v2.0.3) (2018-09-27) | ||
<a name="2.0.2"></a> | ||
@@ -2,0 +7,0 @@ ## [2.0.2](https://github.com/thetutlage/japa/compare/v2.0.1...v2.0.2) (2018-09-25) |
{ | ||
"name": "japa", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"description": "Lean test runner for Node.js", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
126404
3309