New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

alsatian

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

alsatian - npm Package Compare versions

Comparing version 1.0.0-alpha.4 to 1.0.0-alpha.5

CONTRIBUTING.md

4

core/errors/error-match-error.js

@@ -13,6 +13,6 @@ "use strict";

if (expectedErrorType || expectedErrorMessage) {
if (expectedErrorType === undefined || expectedErrorType === null) {
if (expectedErrorType === undefined || expectedErrorType === null || (expectedErrorMessage && actualError instanceof expectedErrorType && expectedErrorMessage !== actualError.message)) {
this._message = "Expected an error with message \"" + expectedErrorMessage + "\" to " + (!shouldMatch ? "not " : "") + "have been thrown, but it was" + (!shouldMatch ? "" : "n't") + ".";
}
else if (expectedErrorMessage === undefined) {
else if (expectedErrorMessage === undefined || (actualError && !(actualError instanceof expectedErrorType) && expectedErrorMessage === actualError.message)) {
this._message = "Expected an error of type " + expectedErrorType["name"] + " to " + (!shouldMatch ? "not " : "") + "have been thrown, but " + (shouldMatch ? actualError["name"] + " was thrown instead" : "it was") + ".";

@@ -19,0 +19,0 @@ }

@@ -0,21 +1,79 @@

/**
* Allows checking of test outcomes
* @param actualValue - the value or function under test
*/
export declare function Expect(actualValue: any): Matcher;
/**
* Gives functionality to ensure the outcome of a test is as expected
*/
export declare class Matcher {
private _actualValue;
private _shouldMatch;
constructor(actualValue: any);
/**
* Any subsequent matcher function will be looking for the opposite criteria
*/
not: Matcher;
constructor(actualValue: any);
/**
* Checks that a value is identical to another
* @param expectedValue - the value that will be used to match
*/
toBe(expectedValue: any): void;
/**
* Checks that a value is equal to another (for objects the function will check for deep equality)
* @param expectedValue - the value that will be used to match
*/
toEqual(expectedValue: any): void;
private _checkObjectsAreDeepEqual(objectA, objectB);
toMatch(regex: any): void;
/**
* Checks that a value conforms to a regular expression
* @param regex - the regular expression that the actual value should match
*/
toMatch(regex: RegExp): void;
/**
* Checks that a value is not undefined
*/
toBeDefined(): void;
/**
* Checks that a value is null
*/
toBeNull(): void;
/**
* Checks that a value is equivalent to boolean true
*/
toBeTruthy(): void;
/**
* Checks that a string contains another string or an array contains a specific item
* @param expectedContent - the string or array item that the value should contain
*/
toContain(expectedContent: any): void;
toBeLessThan(upperLimit: any): void;
toBeGreaterThan(lowerLimit: any): void;
/**
* Checks that a number is less than a given limit
* @param upperLimit - the number that the number under test should be less than
*/
toBeLessThan(upperLimit: number): void;
/**
* Checks that a number is greater than a given limit
* @param lowerLimit - the number that the number under test should be greater than
*/
toBeGreaterThan(lowerLimit: number): void;
/**
* Checks that a function throws an error when executed
*/
toThrow(): void;
toThrowError(errorType: (...args: Array<any>) => Error, errorMessage: string): void;
/**
* Checks that a function throws a specific error
* @param errorType - the type of error that should be thrown
* @param errorMessage - the message that the error should have
*/
toThrowError(errorType: new (...args: Array<any>) => Error, errorMessage: string): void;
/**
* Checks that a spy has been called
*/
toHaveBeenCalled(): void;
/**
* Checks that a spy has been called with the specified arguments
* @param args - a list of arguments that the spy should have been called with
*/
toHaveBeenCalledWith(...args: Array<any>): void;
}
"use strict";
var _namespace_1 = require("./errors/_namespace");
/**
* Allows checking of test outcomes
* @param actualValue - the value or function under test
*/
function Expect(actualValue) {

@@ -7,2 +11,5 @@ return new Matcher(actualValue);

exports.Expect = Expect;
/**
* Gives functionality to ensure the outcome of a test is as expected
*/
var Matcher = (function () {

@@ -14,2 +21,5 @@ function Matcher(actualValue) {

Object.defineProperty(Matcher.prototype, "not", {
/**
* Any subsequent matcher function will be looking for the opposite criteria
*/
get: function () {

@@ -22,2 +32,6 @@ this._shouldMatch = !this._shouldMatch;

});
/**
* Checks that a value is identical to another
* @param expectedValue - the value that will be used to match
*/
Matcher.prototype.toBe = function (expectedValue) {

@@ -28,2 +42,6 @@ if (expectedValue !== this._actualValue === this._shouldMatch) {

};
/**
* Checks that a value is equal to another (for objects the function will check for deep equality)
* @param expectedValue - the value that will be used to match
*/
Matcher.prototype.toEqual = function (expectedValue) {

@@ -63,2 +81,6 @@ if (expectedValue != this._actualValue === this._shouldMatch) {

};
/**
* Checks that a value conforms to a regular expression
* @param regex - the regular expression that the actual value should match
*/
Matcher.prototype.toMatch = function (regex) {

@@ -69,2 +91,5 @@ if (!regex.test(this._actualValue) === this._shouldMatch) {

};
/**
* Checks that a value is not undefined
*/
Matcher.prototype.toBeDefined = function () {

@@ -75,2 +100,5 @@ if (this._actualValue === undefined === this._shouldMatch) {

};
/**
* Checks that a value is null
*/
Matcher.prototype.toBeNull = function () {

@@ -81,2 +109,5 @@ if (this._actualValue !== null === this._shouldMatch) {

};
/**
* Checks that a value is equivalent to boolean true
*/
Matcher.prototype.toBeTruthy = function () {

@@ -87,2 +118,6 @@ if ((this._actualValue && !this._shouldMatch) || (!this._actualValue && this._shouldMatch)) {

};
/**
* Checks that a string contains another string or an array contains a specific item
* @param expectedContent - the string or array item that the value should contain
*/
Matcher.prototype.toContain = function (expectedContent) {

@@ -93,2 +128,6 @@ if (this._actualValue.indexOf(expectedContent) === -1 === this._shouldMatch) {

};
/**
* Checks that a number is less than a given limit
* @param upperLimit - the number that the number under test should be less than
*/
Matcher.prototype.toBeLessThan = function (upperLimit) {

@@ -99,2 +138,6 @@ if (this._actualValue < upperLimit !== this._shouldMatch) {

};
/**
* Checks that a number is greater than a given limit
* @param lowerLimit - the number that the number under test should be greater than
*/
Matcher.prototype.toBeGreaterThan = function (lowerLimit) {

@@ -105,5 +148,7 @@ if (this._actualValue > lowerLimit !== this._shouldMatch) {

};
/**
* Checks that a function throws an error when executed
*/
Matcher.prototype.toThrow = function () {
var threwError = false;
var actualError;
var errorThrown;
try {

@@ -113,9 +158,16 @@ this._actualValue();

catch (error) {
actualError = error;
threwError = true;
if (!this._shouldMatch) {
throw new _namespace_1.ErrorMatchError(error, this._shouldMatch);
}
errorThrown = error;
}
if (!threwError === this._shouldMatch) {
throw new _namespace_1.ErrorMatchError(actualError, this._shouldMatch);
if (this._shouldMatch && errorThrown === undefined) {
throw new _namespace_1.ErrorMatchError(undefined, this._shouldMatch);
}
};
/**
* Checks that a function throws a specific error
* @param errorType - the type of error that should be thrown
* @param errorMessage - the message that the error should have
*/
Matcher.prototype.toThrowError = function (errorType, errorMessage) {

@@ -137,2 +189,5 @@ var threwRightError = false;

};
/**
* Checks that a spy has been called
*/
Matcher.prototype.toHaveBeenCalled = function () {

@@ -143,2 +198,6 @@ if (this._actualValue.calls.length === 0 === this._shouldMatch) {

};
/**
* Checks that a spy has been called with the specified arguments
* @param args - a list of arguments that the spy should have been called with
*/
Matcher.prototype.toHaveBeenCalledWith = function () {

@@ -149,3 +208,6 @@ var args = [];

}
if (this._actualValue.calls.filter(function (call) { return call.args.filter(function (arg, index) { return arg === args[index]; }) && call.args.length === args.length; }).length === 0 === this._shouldMatch) {
if (this._actualValue.calls.filter(function (call) {
return call.args.filter(function (arg, index) { return arg === args[index]; }).length === args.length &&
call.args.length === args.length; // and the call has the same amount of arguments
}).length === 0 === this._shouldMatch) {
throw new _namespace_1.FunctionCallMatchError(this._actualValue, this._shouldMatch, args);

@@ -152,0 +214,0 @@ }

@@ -31,12 +31,12 @@ "use strict";

this._currentTestSet = testSet;
if (this._currentTestSet.testFixtures.length === 0) {
process.stderr.write("no tests to run\n");
var totalTestCount = this._currentTestSet.testFixtures
.filter(function (x) { return x.tests.length > 0; })
.map(function (x) { return x.tests.map(function (y) { return y.testCases.length; })
.reduce(function (a, b) { return a + b; }, 0); })
.reduce(function (a, b) { return a + b; }, 0);
if (totalTestCount === 0) {
process.stderr.write("no tests to run");
process.exit(1);
}
else {
var totalTestCount = this._currentTestSet.testFixtures
.filter(function (x) { return x.tests.length > 0; })
.map(function (x) { return x.tests.map(function (y) { return y.testCases.length; })
.reduce(function (a, b) { return a + b; }); })
.reduce(function (a, b) { return a + b; });
process.stdout.write("TAP version 13\n");

@@ -83,2 +83,3 @@ process.stdout.write("1.." + totalTestCount + "\n");

TestRunner.prototype._handleError = function (error, test, testCaseArguments) {
this._teardown();
this._testsFailed = true;

@@ -93,7 +94,8 @@ process.stdout.write("not ok " + this._getTestDescription(test, testCaseArguments) + "\n");

}
this._teardown();
this._runNextTestCase();
};
TestRunner.prototype._notifySuccess = function (test, testCaseArguments) {
this._teardown();
process.stdout.write("ok " + this._getTestDescription(test, testCaseArguments) + "\n");
this._teardown();
this._runNextTestCase();
};

@@ -108,3 +110,2 @@ TestRunner.prototype._teardown = function () {

}
this._runNextTestCase();
};

@@ -120,2 +121,3 @@ TestRunner.prototype._exit = function () {

TestRunner.prototype._runNextTestFixture = function () {
var _this = this;
this._currentTestFixtureIndex++;

@@ -132,3 +134,5 @@ this._currentTestIndex = 0;

else {
this._runTest(this._currentTestSet.testFixtures[this._currentTestFixtureIndex], this._currentTestSet.testFixtures[this._currentTestFixtureIndex].tests[this._currentTestIndex], this._currentTestSet.testFixtures[this._currentTestFixtureIndex].tests[this._currentTestIndex].testCases[this._currentTestCaseIndex].arguments);
setTimeout(function () {
_this._runTest(_this._currentTestSet.testFixtures[_this._currentTestFixtureIndex], _this._currentTestSet.testFixtures[_this._currentTestFixtureIndex].tests[_this._currentTestIndex], _this._currentTestSet.testFixtures[_this._currentTestFixtureIndex].tests[_this._currentTestIndex].testCases[_this._currentTestCaseIndex].arguments);
});
}

@@ -135,0 +139,0 @@ };

{
"name": "alsatian",
"version": "1.0.0-alpha.4",
"version": "1.0.0-alpha.5",
"description": "TypeScript testing framework with test cases",

@@ -17,2 +17,3 @@ "main": "./core/alsatian-core.js",

"unit-tests": "istanbul cover ./cli/alsatian-cli.js \"./test/**/*.spec.js\" && npm run remap-coverage",
"debug-unit-tests": "node-debug ./cli/alsatian-cli.js \"./test/**/*.spec.js\"",
"remap-coverage": "remap-istanbul -i coverage/coverage.json --output coverage/report --type html"

@@ -47,2 +48,3 @@ },

"istanbul": "^0.4.3",
"node-inspector": "^0.12.8",
"remap-istanbul": "^0.6.4",

@@ -49,0 +51,0 @@ "rewire": "^2.5.1",

@@ -83,4 +83,11 @@ {

"./test/unit-tests/expect-tests/to-be-null.spec.ts",
"./test/unit-tests/expect-tests/to-be-truthy.spec.ts",
"./test/unit-tests/expect-tests/to-be.spec.ts",
"./test/unit-tests/expect-tests/to-contain.spec.ts",
"./test/unit-tests/expect-tests/to-equal.spec.ts",
"./test/unit-tests/expect-tests/to-have-been-called-with.spec.ts",
"./test/unit-tests/expect-tests/to-have-been-called.spec.ts",
"./test/unit-tests/expect-tests/to-match.spec.ts",
"./test/unit-tests/expect-tests/to-throw-error.spec.ts",
"./test/unit-tests/expect-tests/to-throw.spec.ts",
"./test/unit-tests/spying/spy-call.spec.ts",

@@ -93,2 +100,4 @@ "./test/unit-tests/spying/spy-on.spec.ts",

"./test/unit-tests/spying/spy/call.spec.ts",
"./test/unit-tests/test-runner/no-tests-error.spec.ts",
"./test/unit-tests/test-runner/pre-test.spec.ts",
"./test/unit-tests/test-set/load-test.spec.ts",

@@ -95,0 +104,0 @@ "./typings/index.d.ts"

Sorry, the diff of this file is too big to display

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

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

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

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

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

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

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

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

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