Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aft-core

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aft-core - npm Package Compare versions

Comparing version 4.0.1 to 5.0.0

dist/src/helpers/verifier-matcher.d.ts

2

dist/src/helpers/idisposable.d.ts

@@ -17,3 +17,3 @@ /**

export interface IDisposable {
dispose(error?: Error): Promise<void>;
dispose(error?: any): Promise<void>;
}

@@ -13,2 +13,4 @@ /** configuration */

export * from './helpers/using';
export * from './helpers/verifier';
export * from './helpers/verifier-matcher';
export * from './helpers/wait';

@@ -40,4 +42,1 @@ /** plugins */

export * from './plugins/test-cases/test-status';
/** wrappers */
export * from './wrappers/should';
export * from './wrappers/test-wrapper';

@@ -25,2 +25,4 @@ "use strict";

__exportStar(require("./helpers/using"), exports);
__exportStar(require("./helpers/verifier"), exports);
__exportStar(require("./helpers/verifier-matcher"), exports);
__exportStar(require("./helpers/wait"), exports);

@@ -52,5 +54,2 @@ /** plugins */

__exportStar(require("./plugins/test-cases/test-status"), exports);
/** wrappers */
__exportStar(require("./wrappers/should"), exports);
__exportStar(require("./wrappers/test-wrapper"), exports);
//# sourceMappingURL=index.js.map

@@ -125,12 +125,15 @@ "use strict";

return __awaiter(this, void 0, void 0, function () {
var plugins;
return __generator(this, function (_a) {
switch (_a.label) {
var plugins, _a, _b, _c;
return __generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, this.getEnabledPlugins()];
case 1:
plugins = _a.sent();
plugins = _d.sent();
if (plugins === null || plugins === void 0 ? void 0 : plugins.length) {
return [2 /*return*/, plugins[0]];
}
return [2 /*return*/, null];
_b = (_a = Promise).reject;
_c = this.constructor.name + ": unable to find enabled plugin in: [";
return [4 /*yield*/, this.getPluginNames().then(function (n) { return n.join(','); })];
case 2: return [2 /*return*/, _b.apply(_a, [_c + (_d.sent()) + "]"])];
}

@@ -137,0 +140,0 @@ });

@@ -94,3 +94,3 @@ "use strict";

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this._logMgr.trace(err)];
case 1:

@@ -123,3 +123,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this._logMgr.trace(err)];
case 1:

@@ -126,0 +126,0 @@ _a.sent();

@@ -94,3 +94,3 @@ "use strict";

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this._logMgr.trace(err)];
case 1:

@@ -123,3 +123,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this._logMgr.trace(err)];
case 1:

@@ -126,0 +126,0 @@ _a.sent();

@@ -113,2 +113,4 @@ "use strict";

d = new Date().toLocaleTimeString();
level = level || logging_level_1.LoggingLevel.none;
message = message || '';
_a = d + " - ";

@@ -139,2 +141,4 @@ return [4 /*yield*/, this.logName()];

break;
case logging_level_1.LoggingLevel.none:
break;
default:

@@ -141,0 +145,0 @@ console.log(colors.gray(out));

@@ -7,3 +7,3 @@ import { AbstractPluginManager, IPluginManagerOptions } from "../abstract-plugin-manager";

export interface ITestCasePluginManagerOptions extends ITestCasePluginOptions, IPluginManagerOptions {
_logMgr?: LoggingPluginManager;
logMgr?: LoggingPluginManager;
}

@@ -24,3 +24,3 @@ /**

export declare class TestCasePluginManager extends AbstractPluginManager<AbstractTestCasePlugin, ITestCasePluginOptions> {
private _logMgr;
readonly logMgr: LoggingPluginManager;
constructor(options?: ITestCasePluginManagerOptions);

@@ -27,0 +27,0 @@ getTestCase(testId: string): Promise<ITestCase>;

@@ -75,3 +75,3 @@ "use strict";

var _this = _super.call(this, ts_simple_nameof_1.nameof(TestCasePluginManager).toLowerCase(), options) || this;
_this._logMgr = (options === null || options === void 0 ? void 0 : options._logMgr) || new logging_plugin_manager_1.LoggingPluginManager({ logName: ts_simple_nameof_1.nameof(TestCasePluginManager), pluginNames: [] });
_this.logMgr = (options === null || options === void 0 ? void 0 : options.logMgr) || new logging_plugin_manager_1.LoggingPluginManager({ logName: ts_simple_nameof_1.nameof(TestCasePluginManager) });
return _this;

@@ -95,3 +95,3 @@ }

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this.logMgr.trace(err)];
case 1:

@@ -124,3 +124,3 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this.logMgr.trace(err)];
case 1:

@@ -153,6 +153,6 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, this._logMgr.warn(err)];
case 0: return [4 /*yield*/, this.logMgr.trace(err)];
case 1:
_a.sent();
return [2 /*return*/, { success: false, message: err }];
return [2 /*return*/, { success: true, message: err + " - so run all tests" }];
}

@@ -159,0 +159,0 @@ });

@@ -78,3 +78,3 @@ "use strict";

it('can wait for a condition with a maximum duration', function () { return __awaiter(void 0, void 0, void 0, function () {
var now, err_1, elapsed;
var now, elapsed;
return __generator(this, function (_a) {

@@ -84,5 +84,2 @@ switch (_a.label) {

now = new Date().getTime();
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
return [4 /*yield*/, wait_1.wait.untilTrue(function () { return __awaiter(void 0, void 0, void 0, function () {

@@ -93,5 +90,3 @@ return __generator(this, function (_a) {

// always wait 1 ms and return false
return [4 /*yield*/, new Promise(function (resolve, reject) {
setTimeout(resolve, 1);
})];
return [4 /*yield*/, new Promise(function (resolve, reject) { return setTimeout(resolve, 1); })];
case 1:

@@ -104,12 +99,7 @@ // always wait 1 ms and return false

});
}); }, 200)];
case 2:
}); }, 200).catch(function (err) {
/* do nothing */
})];
case 1:
_a.sent();
expect(true).toEqual(false); // force failure
return [3 /*break*/, 4];
case 3:
err_1 = _a.sent();
expect(true).toEqual(true);
return [3 /*break*/, 4];
case 4:
elapsed = converter_1.convert.toElapsedMs(now);

@@ -116,0 +106,0 @@ expect(elapsed).toBeGreaterThanOrEqual(200);

@@ -52,3 +52,3 @@ "use strict";

switch (_a.label) {
case 0: return [4 /*yield*/, src_1.should({ expect: function () { return expect(1 + 1).toBe(2); }, description: '1 plus 1 is 2' })];
case 0: return [4 /*yield*/, src_1.verify(function () { return (1 + 1); }).returns(2).withDescription('1 plus 1 is 2')];
case 1:

@@ -63,32 +63,30 @@ _a.sent();

switch (_a.label) {
case 0: return [4 /*yield*/, src_1.should({
expect: function (tw) { return __awaiter(void 0, void 0, void 0, function () {
var count, result, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
count = 10;
result = true;
i = 0;
_a.label = 1;
case 1:
if (!(i < count)) return [3 /*break*/, 5];
return [4 /*yield*/, tw.logMgr.info("running count: " + i)];
case 2:
_a.sent();
return [4 /*yield*/, tw.logMgr.warn("random string: " + src_1.rand.getString())];
case 3:
_a.sent();
result = result && expect(i).not.toBeNaN();
_a.label = 4;
case 4:
i++;
return [3 /*break*/, 1];
case 5: return [2 /*return*/, result];
}
});
}); },
testCases: ['C1234', 'C2345'],
description: 'some tests require lots of actions'
})];
case 0: return [4 /*yield*/, src_1.verify(function (v) { return __awaiter(void 0, void 0, void 0, function () {
var count, result, i;
return __generator(this, function (_a) {
switch (_a.label) {
case 0:
count = 10;
result = true;
i = 0;
_a.label = 1;
case 1:
if (!(i < count)) return [3 /*break*/, 5];
return [4 /*yield*/, v.logMgr.info("running count: " + i)];
case 2:
_a.sent();
return [4 /*yield*/, v.logMgr.warn("random string: " + src_1.rand.getString())];
case 3:
_a.sent();
result = result && expect(i).not.toBeNaN();
_a.label = 4;
case 4:
i++;
return [3 /*break*/, 1];
case 5: return [2 /*return*/, count];
}
});
}); }).withTestId('C1234').and.withTestId('C2345')
.and.withDescription('some tests require lots of actions')
.returns(10)];
case 1:

@@ -95,0 +93,0 @@ _a.sent();

{
"name": "aft-core",
"version": "4.0.1",
"version": "5.0.0",
"description": "Automation Framework for Testing (AFT) package supporting JavaScript unit, integration and functional testing",

@@ -15,3 +15,3 @@ "repository": {

"pretest": "yarn build",
"test": "jasmine **/*-spec.js",
"test": "jasmine ./dist/test/**/*-spec.js",
"coverage": "nyc yarn test"

@@ -32,3 +32,3 @@ },

},
"homepage": "https://github.com/bicarbon8/automated-functional-testing/packages/aft-core#readme",
"homepage": "https://github.com/bicarbon8/automated-functional-testing#readme",
"dependencies": {

@@ -49,3 +49,3 @@ "colors": "^1.4.0",

},
"gitHead": "64a740a2dba7f011d06c6d3c83a2345c4e1a0adf"
"gitHead": "daa8db59af0188cea7f1e1af1b3900b4f9cf185e"
}

@@ -28,2 +28,3 @@ # AFT-Core

- **using** - automatically call the `dispose` function of a class that implements the `IDisposable` interface when done
- **verify** - a function accepting an `assertion` function that simplifies usage of a `Verifier` within your _Jasmine_ or _Mocha_ tests
- **MachineInfo** - get details of the host machine and user running the tests

@@ -119,6 +120,4 @@ - **OptionsManager** - read in configuration settings from a passed in `object` with fallback to the `aftconfig.json` file which enables specifying environment variables for values

## Wrappers
the `TestWrapper` and `should` functions of `aft-core` enable testing with pre-execution filtering based on integration with external test case and defect managers via plugin packages supporting each (see examples above).
- **should** - a function accepting a `TestWrapperOptions` object that simplifies usage of a `TestWrapper` within your _Jasmine_ or _Mocha_ tests
- **TestWrapper** - the primary way tests should be executed to enable integration with external systems and logging to any supported logging plugins
## Testing with the Verifier
the `Verifier` class and `verify` functions of `aft-core` enable testing with pre-execution filtering based on integration with external test case and defect managers via plugin packages supporting each (see examples above).

@@ -130,3 +129,3 @@ ```typescript

/**
* the `should(options)` function
* the `verify(assertion).returns(expectation)` function
* checks any specified `AbstractTestCasePlugin`

@@ -139,8 +138,9 @@ * and `AbstractDefectPlugin` implementations

*/
await should({expect: () => expect(feature.performAction()).toEqual('result of action'),
testCases: ['C1234'],
description: 'expect that performAction will return \'result of action\''
});
await verify(async () => await feature.performAction())
.withTestId('C1234')
.and.withKnownDefectId('DEFECT-123')
.and.withDescription('expect that performAction will return \'result of action\'')
.returns('result of action');
});
});
```

@@ -17,3 +17,3 @@ /**

export interface IDisposable {
dispose(error?: Error): Promise<void>;
dispose(error?: any): Promise<void>;
}

@@ -19,3 +19,3 @@ import { Func } from "./custom-types";

export async function using<T extends IDisposable>(disposable: T, func: Func<T, void | Promise<void>>): Promise<void> {
let err: Error;
let err: any;
try {

@@ -22,0 +22,0 @@ await Promise.resolve(func(disposable));

@@ -13,2 +13,4 @@ /** configuration */

export * from './helpers/using';
export * from './helpers/verifier';
export * from './helpers/verifier-matcher';
export * from './helpers/wait';

@@ -39,5 +41,2 @@ /** plugins */

export * from './plugins/test-cases/test-exception';
export * from './plugins/test-cases/test-status';
/** wrappers */
export * from './wrappers/should';
export * from './wrappers/test-wrapper';
export * from './plugins/test-cases/test-status';

@@ -101,3 +101,3 @@ import { AbstractPlugin, IPluginOptions } from "./abstract-plugin";

}
return null;
return Promise.reject(`${this.constructor.name}: unable to find enabled plugin in: [${await this.getPluginNames().then(n => n.join(','))}]`);
}

@@ -104,0 +104,0 @@

@@ -36,3 +36,3 @@ import { AbstractPluginManager, IPluginManagerOptions } from "../abstract-plugin-manager";

}).catch(async (err) => {
await this._logMgr.warn(err);
await this._logMgr.trace(err);
return null;

@@ -47,3 +47,3 @@ });

}).catch(async (err) => {
await this._logMgr.warn(err);
await this._logMgr.trace(err);
return null;

@@ -50,0 +50,0 @@ });

@@ -37,3 +37,3 @@ import { AbstractPluginManager, IPluginManagerOptions } from "../abstract-plugin-manager";

}).catch(async (err) => {
await this._logMgr.warn(err);
await this._logMgr.trace(err);
return null;

@@ -48,3 +48,3 @@ });

}).catch(async (err) => {
await this._logMgr.warn(err);
await this._logMgr.trace(err);
return [];

@@ -51,0 +51,0 @@ });

@@ -39,2 +39,4 @@ import { LoggingLevel } from "./logging-level";

let d: string = new Date().toLocaleTimeString();
level = level || LoggingLevel.none;
message = message || '';
let out: string = `${d} - ${await this.logName()} - ${level.logString} - ${message}`;

@@ -62,2 +64,4 @@ switch (level) {

break;
case LoggingLevel.none:
break;
default:

@@ -64,0 +68,0 @@ console.log(colors.gray(out));

@@ -9,3 +9,3 @@ import { AbstractPluginManager, IPluginManagerOptions } from "../abstract-plugin-manager";

export interface ITestCasePluginManagerOptions extends ITestCasePluginOptions, IPluginManagerOptions {
_logMgr?: LoggingPluginManager;
logMgr?: LoggingPluginManager;
}

@@ -27,7 +27,7 @@

export class TestCasePluginManager extends AbstractPluginManager<AbstractTestCasePlugin, ITestCasePluginOptions> {
private _logMgr: LoggingPluginManager;
readonly logMgr: LoggingPluginManager;
constructor(options?: ITestCasePluginManagerOptions) {
super(nameof(TestCasePluginManager).toLowerCase(), options);
this._logMgr = options?._logMgr || new LoggingPluginManager({logName: nameof(TestCasePluginManager), pluginNames: []});
this.logMgr = options?.logMgr || new LoggingPluginManager({logName: nameof(TestCasePluginManager)});
}

@@ -40,3 +40,3 @@

}).catch(async (err) => {
await this._logMgr.warn(err);
await this.logMgr.trace(err);
return null;

@@ -51,3 +51,3 @@ });

}).catch(async (err) => {
await this._logMgr.warn(err);
await this.logMgr.trace(err);
return null;

@@ -62,4 +62,4 @@ })

}).catch(async (err) => {
await this._logMgr.warn(err);
return {success: false, message: err};
await this.logMgr.trace(err);
return {success: true, message: `${err} - so run all tests`};
});

@@ -66,0 +66,0 @@ }

@@ -29,18 +29,12 @@ import { convert } from "../../src/helpers/converter";

let now: number = new Date().getTime();
try
{
await wait.untilTrue(async () => {
// always wait 1 ms and return false
await new Promise<void>((resolve, reject) => {
setTimeout(resolve, 1);
});
TestHelper.count += 1;
return false;
}, 200);
await wait.untilTrue(async () => {
// always wait 1 ms and return false
await new Promise<void>((resolve, reject) => setTimeout(resolve, 1));
TestHelper.count += 1;
return false;
}, 200).catch((err) => {
/* do nothing */
});
expect(true).toEqual(false); // force failure
} catch (err) {
expect(true).toEqual(true);
}
let elapsed: number = convert.toElapsedMs(now);

@@ -47,0 +41,0 @@ expect(elapsed).toBeGreaterThanOrEqual(200);

@@ -1,2 +0,2 @@

import { rand, should } from "../src";
import { rand, verify } from "../src";

@@ -15,21 +15,19 @@ var consoleLog = console.log;

it('is simple to integrate into existing expectations', async () => {
await should({expect: () => expect(1 + 1).toBe(2), description: '1 plus 1 is 2'});
await verify(() => (1 + 1)).returns(2).withDescription('1 plus 1 is 2');
});
it('can be used to wrap large blocks of code', async () => {
await should({
expect: async (tw) => {
let count: number = 10;
let result: boolean = true;
for (var i=0; i<count; i++) {
await tw.logMgr.info(`running count: ${i}`);
await tw.logMgr.warn(`random string: ${rand.getString()}`);
result = result && expect(i).not.toBeNaN();
}
return result;
},
testCases: ['C1234', 'C2345'],
description: 'some tests require lots of actions'
});
await verify(async (v) => {
let count: number = 10;
let result: boolean = true;
for (var i=0; i<count; i++) {
await v.logMgr.info(`running count: ${i}`);
await v.logMgr.warn(`random string: ${rand.getString()}`);
result = result && expect(i).not.toBeNaN();
}
return count;
}).withTestId('C1234').and.withTestId('C2345')
.and.withDescription('some tests require lots of actions')
.returns(10);
});
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc