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

aws-testing-library

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aws-testing-library - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

6

lib/chai/api.js

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(props, api_1.expectedProps);
(0, common_1.verifyProps)(props, api_1.expectedProps);
const { url, method, params, data, headers } = props;
const received = await api_2.getResponse(url, method, params, data, headers);
const received = await (0, api_2.getResponse)(url, method, params, data, headers);
const deepEquals = eql(expected, received);

@@ -22,3 +22,3 @@ return {

chai.Assertion.addMethod('response', async function (expected) {
const wrapped = utils_1.wrapWithRetries(attemptApi);
const wrapped = (0, utils_1.wrapWithRetries)(attemptApi);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -25,0 +25,0 @@ eql,

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { pattern }), cloudwatch_1.expectedProps);
const { region, function: functionName, startTime = common_1.epochDateMinusHours(1), } = props;
const { events } = await cloudwatch_2.filterLogEvents(region, functionName, startTime, pattern);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { pattern }), cloudwatch_1.expectedProps);
const { region, function: functionName, startTime = (0, common_1.epochDateMinusHours)(1), } = props;
const { events } = await (0, cloudwatch_2.filterLogEvents)(region, functionName, startTime, pattern);
const found = events.length > 0;

@@ -22,3 +22,3 @@ return {

chai.Assertion.addMethod('log', async function (pattern) {
const wrapped = utils_1.wrapWithRetries(attemptCloudwatch);
const wrapped = (0, utils_1.wrapWithRetries)(attemptCloudwatch);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -25,0 +25,0 @@ pattern,

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { key }), dynamoDb_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { key }), dynamoDb_1.expectedProps);
const { region, table } = props;
let received = await dynamoDb_2.getItem(region, table, key);
let received = await (0, dynamoDb_2.getItem)(region, table, key);
const printKey = JSON.stringify(key);

@@ -17,3 +17,3 @@ if (received && expected) {

if (!strict) {
received = dynamoDb_1.removeKeysFromItemForNonStrictComparison(received, expected);
received = (0, dynamoDb_1.removeKeysFromItemForNonStrictComparison)(received, expected);
}

@@ -38,3 +38,3 @@ const deepEquals = eql(expected, received);

chai.Assertion.addMethod('item', async function (key, expected, strict = true) {
const wrapped = utils_1.wrapWithRetries(attemptDynamoDb);
const wrapped = (0, utils_1.wrapWithRetries)(attemptDynamoDb);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -41,0 +41,0 @@ eql,

@@ -11,11 +11,11 @@ "use strict";

const awsTesting = function (chai, utils) {
api_1.default(chai, utils);
cloudwatch_1.default(chai);
dynamoDb_1.default(chai, utils);
kinesis_1.default(chai);
s3_1.default(chai, utils);
sqs_1.default(chai);
stepFunctions_1.default(chai);
(0, api_1.default)(chai, utils);
(0, cloudwatch_1.default)(chai);
(0, dynamoDb_1.default)(chai, utils);
(0, kinesis_1.default)(chai);
(0, s3_1.default)(chai, utils);
(0, sqs_1.default)(chai);
(0, stepFunctions_1.default)(chai);
};
exports.default = awsTesting;
//# sourceMappingURL=index.js.map

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { matcher }), kinesis_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { matcher }), kinesis_1.expectedProps);
const { region, stream, timeout = 10 * 1000, pollEvery = 500 } = props;
const found = await kinesis_2.existsInStream(region, stream, matcher, timeout, pollEvery);
const found = await (0, kinesis_2.existsInStream)(region, stream, matcher, timeout, pollEvery);
this.assert(found, `expected ${stream} to have record`, `expected ${stream} not to have record`);

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

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { key }), s3_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { key }), s3_1.expectedProps);
const { region, bucket } = props;
const { body: received, found } = await s3_2.getObject(region, bucket, key);
const { body: received, found } = await (0, s3_2.getObject)(region, bucket, key);
if (found && expected) {

@@ -33,3 +33,3 @@ // check equality as well

chai.Assertion.addMethod('object', async function (key, expected) {
const wrapped = utils_1.wrapWithRetries(attemptS3);
const wrapped = (0, utils_1.wrapWithRetries)(attemptS3);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -36,0 +36,0 @@ eql,

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { matcher }), sqs_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { matcher }), sqs_1.expectedProps);
const { region, queueUrl } = props;
const found = await sqs_2.existsInQueue(region, queueUrl, matcher);
const found = await (0, sqs_2.existsInQueue)(region, queueUrl, matcher);
return {

@@ -21,3 +21,3 @@ message: `expected ${queueUrl} to have message`,

chai.Assertion.addMethod('message', async function (matcher) {
const wrapped = utils_1.wrapWithRetries(attemptSqs);
const wrapped = (0, utils_1.wrapWithRetries)(attemptSqs);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -24,0 +24,0 @@ matcher,

@@ -9,5 +9,5 @@ "use strict";

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { state }), stepFunctions_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { state }), stepFunctions_1.expectedProps);
const { region, stateMachineArn } = props;
const received = await stepFunctions_2.getCurrentState(region, stateMachineArn);
const received = await (0, stepFunctions_2.getCurrentState)(region, stateMachineArn);
const pass = received === state;

@@ -22,5 +22,5 @@ return {

const props = this._obj;
common_1.verifyProps(Object.assign(Object.assign({}, props), { state }), stepFunctions_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { state }), stepFunctions_1.expectedProps);
const { region, stateMachineArn } = props;
const states = await stepFunctions_2.getStates(region, stateMachineArn);
const states = await (0, stepFunctions_2.getStates)(region, stateMachineArn);
const pass = states.includes(state);

@@ -35,3 +35,3 @@ return {

chai.Assertion.addMethod('atState', async function (state) {
const wrapped = utils_1.wrapWithRetries(attemptAtState);
const wrapped = (0, utils_1.wrapWithRetries)(attemptAtState);
const { pass, message, negateMessage } = await wrapped.apply(this, [

@@ -43,3 +43,3 @@ state,

chai.Assertion.addMethod('state', async function (state) {
const wrapped = utils_1.wrapWithRetries(attemptHaveState);
const wrapped = (0, utils_1.wrapWithRetries)(attemptHaveState);
const { pass, message, negateMessage } = await wrapped.apply(this, [state]);

@@ -46,0 +46,0 @@ this.assert(pass, message, negateMessage);

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

// retry
await common_1.sleep(pollEvery);
await (0, common_1.sleep)(pollEvery);
result = await matcher.apply(this, args);

@@ -25,0 +25,0 @@ }

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

const toReturnResponse = async function (props, expected) {
common_1.verifyProps(Object.assign({}, props), api_1.expectedProps);
(0, common_1.verifyProps)(Object.assign({}, props), api_1.expectedProps);
const { url, method, params, data, headers } = props;

@@ -18,3 +18,3 @@ try {

const hint = this.utils.matcherHint('.toReturnResponse') + os_1.EOL + os_1.EOL;
const received = await api_2.getResponse(url, method, params, data, headers);
const received = await (0, api_2.getResponse)(url, method, params, data, headers);
const pass = this.equals(expected, received);

@@ -31,3 +31,3 @@ const printReceived = this.utils.printReceived(received);

else {
const diffString = jest_diff_1.default(expected, received, {
const diffString = (0, jest_diff_1.diff)(expected, received, {
expand: true,

@@ -43,3 +43,4 @@ });

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -46,0 +47,0 @@ console.error(`Unknown error while getting response: ${e.message}`);

@@ -9,4 +9,4 @@ "use strict";

const toHaveLog = async function (props, pattern) {
index_1.verifyProps(Object.assign(Object.assign({}, props), { pattern }), cloudwatch_1.expectedProps);
const { region, function: functionName, startTime = index_1.epochDateMinusHours(1), } = props;
(0, index_1.verifyProps)(Object.assign(Object.assign({}, props), { pattern }), cloudwatch_1.expectedProps);
const { region, function: functionName, startTime = (0, index_1.epochDateMinusHours)(1), } = props;
try {

@@ -18,3 +18,3 @@ const printFunctionName = this.utils.printExpected(functionName);

const hint = this.utils.matcherHint('.toHaveLog') + os_1.EOL + os_1.EOL;
const { events } = await cloudwatch_2.filterLogEvents(region, functionName, startTime, pattern);
const { events } = await (0, cloudwatch_2.filterLogEvents)(region, functionName, startTime, pattern);
const found = events.length > 0;

@@ -36,3 +36,4 @@ if (found) {

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -39,0 +40,0 @@ console.error(`Unknown error while matching log: ${e.message}`);

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

const toHaveItem = async function (props, key, expected, strict = true) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { key }), dynamoDb_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { key }), dynamoDb_1.expectedProps);
const { region, table } = props;

@@ -19,3 +19,3 @@ try {

const hint = this.utils.matcherHint('.toHaveItem') + os_1.EOL + os_1.EOL;
let received = await dynamoDb_2.getItem(region, table, key);
let received = await (0, dynamoDb_2.getItem)(region, table, key);
// check if item was found

@@ -32,3 +32,3 @@ if (received) {

if (!strict) {
received = dynamoDb_1.removeKeysFromItemForNonStrictComparison(received, expected);
received = (0, dynamoDb_1.removeKeysFromItemForNonStrictComparison)(received, expected);
}

@@ -46,3 +46,3 @@ // we check equality as well

else {
const diffString = jest_diff_1.default(expected, received, {
const diffString = (0, jest_diff_1.diff)(expected, received, {
expand: true,

@@ -66,3 +66,4 @@ });

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -69,0 +70,0 @@ console.error(`Unknown error while looking for item: ${e.message}`);

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

expect.extend({
toBeAtState: utils_1.wrapWithRetries(stepFunctions_1.toBeAtState),
toHaveItem: utils_1.wrapWithRetries(dynamoDb_1.toHaveItem),
toHaveLog: utils_1.wrapWithRetries(cloudwatch_1.toHaveLog),
toHaveMessage: utils_1.wrapWithRetries(sqs_1.toHaveMessage),
toHaveObject: utils_1.wrapWithRetries(s3_1.toHaveObject),
toBeAtState: (0, utils_1.wrapWithRetries)(stepFunctions_1.toBeAtState),
toHaveItem: (0, utils_1.wrapWithRetries)(dynamoDb_1.toHaveItem),
toHaveLog: (0, utils_1.wrapWithRetries)(cloudwatch_1.toHaveLog),
toHaveMessage: (0, utils_1.wrapWithRetries)(sqs_1.toHaveMessage),
toHaveObject: (0, utils_1.wrapWithRetries)(s3_1.toHaveObject),
toHaveRecord: kinesis_1.toHaveRecord,
toHaveState: utils_1.wrapWithRetries(stepFunctions_1.toHaveState),
toHaveState: (0, utils_1.wrapWithRetries)(stepFunctions_1.toHaveState),
toReturnResponse: api_1.toReturnResponse, // synchronous so no need to retry

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

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

const toHaveRecord = async function (props, matcher) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { matcher }), kinesis_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { matcher }), kinesis_1.expectedProps);
const { region, stream, timeout = 10 * 1000, pollEvery = 500 } = props;

@@ -17,3 +17,3 @@ try {

const hint = this.utils.matcherHint('.toHaveRecord') + os_1.EOL + os_1.EOL;
const found = await kinesis_2.existsInStream(region, stream, matcher, timeout, pollEvery);
const found = await (0, kinesis_2.existsInStream)(region, stream, matcher, timeout, pollEvery);
// check if record was found

@@ -34,3 +34,4 @@ if (found) {

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -37,0 +38,0 @@ console.error(`Unknown error while looking for record: ${e.message}`);

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

const toHaveObject = async function (props, key, expected) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { key }), s3_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { key }), s3_1.expectedProps);
const { region, bucket } = props;

@@ -19,3 +19,3 @@ try {

const hint = this.utils.matcherHint('.toHaveObject') + os_1.EOL + os_1.EOL;
const { body: received, found } = await s3_2.getObject(region, bucket, key);
const { body: received, found } = await (0, s3_2.getObject)(region, bucket, key);
// check if object was found

@@ -42,3 +42,3 @@ if (found) {

else {
const diffString = jest_diff_1.default(expected, received, {
const diffString = (0, jest_diff_1.diff)(expected, received, {
expand: true,

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

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -65,0 +66,0 @@ console.error(`Unknown error while looking for object: ${e.message}`);

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

const toHaveMessage = async function (props, matcher) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { matcher }), sqs_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { matcher }), sqs_1.expectedProps);
const { region, queueUrl } = props;

@@ -17,3 +17,3 @@ try {

const hint = this.utils.matcherHint('.toHaveMessage') + os_1.EOL + os_1.EOL;
const found = await sqs_2.existsInQueue(region, queueUrl, matcher);
const found = await (0, sqs_2.existsInQueue)(region, queueUrl, matcher);
// check if record was found

@@ -34,3 +34,4 @@ if (found) {

}
catch (e) {
catch (error) {
const e = error;
// unknown error

@@ -37,0 +38,0 @@ console.error(`Unknown error while looking for message: ${e.message}`);

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

const toBeAtState = async function (props, expected) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { state: expected }), stepFunctions_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { state: expected }), stepFunctions_1.expectedProps);
const { region, stateMachineArn } = props;

@@ -19,3 +19,3 @@ try {

const hint = this.utils.matcherHint('.toBeAtState') + os_1.EOL + os_1.EOL;
const received = await stepFunctions_2.getCurrentState(region, stateMachineArn);
const received = await (0, stepFunctions_2.getCurrentState)(region, stateMachineArn);
const pass = this.equals(expected, received);

@@ -29,3 +29,3 @@ if (pass) {

else {
const diffString = jest_diff_1.default(expected, received, {
const diffString = (0, jest_diff_1.diff)(expected, received, {
expand: true,

@@ -40,3 +40,4 @@ });

}
catch (e) {
catch (error) {
const e = error;
console.error(`Unknown error getting state machine state: ${e.message}`);

@@ -48,3 +49,3 @@ throw e;

const toHaveState = async function (props, expected) {
common_1.verifyProps(Object.assign(Object.assign({}, props), { state: expected }), stepFunctions_1.expectedProps);
(0, common_1.verifyProps)(Object.assign(Object.assign({}, props), { state: expected }), stepFunctions_1.expectedProps);
const { region, stateMachineArn } = props;

@@ -57,3 +58,3 @@ try {

const hint = this.utils.matcherHint('.toHaveState') + os_1.EOL + os_1.EOL;
const states = await stepFunctions_2.getStates(region, stateMachineArn);
const states = await (0, stepFunctions_2.getStates)(region, stateMachineArn);
const pass = states.includes(expected);

@@ -74,3 +75,4 @@ if (pass) {

}
catch (e) {
catch (error) {
const e = error;
console.error(`Unknown error getting state machine states: ${e.message}`);

@@ -77,0 +79,0 @@ throw e;

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

// retry
await common_1.sleep(pollEvery);
await (0, common_1.sleep)(pollEvery);
result = await matcher.apply(this, [

@@ -26,0 +26,0 @@ props,

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

};
const result = await axios_1.default(config);
const result = await (0, axios_1.default)(config);
return { statusCode: result.status, data: result.data };

@@ -18,0 +18,0 @@ };

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

}));
const results = await Promise.all(shardIterators.map((s) => exports.existsInShard(kinesis, s.ShardIterator, matcher, timeout, pollEvery)));
const results = await Promise.all(shardIterators.map((s) => (0, exports.existsInShard)(kinesis, s.ShardIterator, matcher, timeout, pollEvery)));
const exists = results.some((r) => r);

@@ -63,0 +63,0 @@ return exists;

@@ -40,3 +40,4 @@ "use strict";

}
catch (e) {
catch (error) {
const e = error;
if (e.code === 'NoSuchKey') {

@@ -43,0 +44,0 @@ return { body: null, found: false };

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

return await new Promise((resolve, reject) => {
const serverless = child_process_1.spawn('serverless', ['deploy', '--stage', stage]);
const serverless = (0, child_process_1.spawn)('serverless', ['deploy', '--stage', stage]);
console.log(`${os_1.EOL}Deploying Service`);

@@ -11,0 +11,0 @@ serverless.stdout.on('data', (data) => {

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

const sqs = new AWS.SQS({ region });
const queueName = `TestNotificationTopicQueue-${uuid_1.v1()}`;
const queueName = `TestNotificationTopicQueue-${(0, uuid_1.v1)()}`;
const { QueueUrl } = (await sqs

@@ -11,0 +11,0 @@ .createQueue({

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

const newestEvent = events[0];
const name = exports.getEventName(newestEvent);
const name = (0, exports.getEventName)(newestEvent);
return name;

@@ -53,3 +53,3 @@ }

const names = events
.map((event) => exports.getEventName(event))
.map((event) => (0, exports.getEventName)(event))
.filter((name) => !!name);

@@ -56,0 +56,0 @@ return names;

{
"name": "aws-testing-library",
"version": "1.1.2",
"version": "1.1.3",
"description": "Chai and Jest matchers for aws services",

@@ -13,3 +13,4 @@ "scripts": {

"format": "prettier --write src/**/*.ts",
"format:ci": "prettier --list-different src/**/*.ts"
"format:ci": "prettier --list-different src/**/*.ts",
"prepare": "husky install"
},

@@ -40,7 +41,2 @@ "files": [

},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"homepage": "https://github.com/erezrokah/aws-testing-library/#readme",

@@ -50,10 +46,10 @@ "author": "Erez Rokah",

"devDependencies": {
"@commitlint/cli": "^13.0.0",
"@commitlint/config-conventional": "^13.0.0",
"@commitlint/cli": "^16.0.0",
"@commitlint/config-conventional": "^16.0.0",
"@types/chai": "^4.2.12",
"@types/jest": "^26.0.13",
"@types/jest": "^27.0.0",
"@types/jest-diff": "^24.3.0",
"@types/jest-matcher-utils": "^25.1.0",
"@types/mockdate": "^2.0.0",
"@types/node": "^14.6.4",
"@types/node": "^16.0.0",
"@types/uuid": "^8.3.0",

@@ -66,7 +62,7 @@ "@typescript-eslint/eslint-plugin": "^4.7.0",

"eslint-config-prettier": "^6.15.0",
"husky": "^4.0.7",
"jest": "^26.0.0",
"husky": "^7.0.0",
"jest": "^27.0.0",
"mockdate": "^3.0.0",
"prettier": "^2.0.0",
"ts-jest": "^26.4.4",
"ts-jest": "^27.0.0",
"ts-node": "^10.0.0",

@@ -77,5 +73,5 @@ "typescript": "^4.0.5"

"aws-sdk": "^2.678.0",
"axios": "^0.21.0",
"axios": "^0.25.0",
"filter-obj": "^2.0.1",
"jest-diff": "^26.0.0",
"jest-diff": "^27.0.0",
"uuid": "^8.0.0"

@@ -82,0 +78,0 @@ },

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