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

testing-helpers

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

testing-helpers - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

LICENSE

50

build/index.js

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

exports.setMockYCoordinates = setMockYCoordinates;
exports.spyOnActionCreator = spyOnActionCreator;
exports.removeActionCreatorSpy = removeActionCreatorSpy;
exports.createMockGetParamWithTestParamsReference = createMockGetParamWithTestParamsReference;
exports.findTestIDInWrapper = findTestIDInWrapper;
exports.flushPromises = flushPromises;
exports.spyOnActionCreator = spyOnActionCreator;

@@ -16,2 +18,3 @@ var _lodash = _interopRequireDefault(require("lodash"));

// RN helpers
function setMockYCoordinates(_ref) {

@@ -36,10 +39,35 @@ var inputsState = _ref.inputsState,

function findTestIDInWrapper(_ref2) {
var wrapper = _ref2.wrapper,
testID = _ref2.testID,
_ref2$findAll = _ref2.findAll,
findAll = _ref2$findAll === void 0 ? false : _ref2$findAll;
// eslint-disable-next-line no-undef
var attribute = window && _lodash["default"].get(window, 'process.env.VUE_APP_TITLE') ? 'test-id' : 'testID';
function spyOnActionCreator(_ref2) {
var actions = _ref2.actions,
key = _ref2.key;
return jest.spyOn(actions, key).mockReturnValue(_lodash["default"].constant(_lodash["default"].noop));
}
function removeActionCreatorSpy(_ref3) {
var actions = _ref3.actions,
key = _ref3.key;
if (_lodash["default"].isFunction(_lodash["default"].get(actions, "".concat(key, ".mockRestore")))) {
actions[key].mockRestore();
}
}
function createMockGetParamWithTestParamsReference(_ref4) {
var testParams = _ref4.testParams;
return function (key, fallback) {
return _lodash["default"].get(testParams, key, fallback);
};
} // Shared helpers
function findTestIDInWrapper(_ref5) {
var wrapper = _ref5.wrapper,
testID = _ref5.testID,
_ref5$findAll = _ref5.findAll,
findAll = _ref5$findAll === void 0 ? false : _ref5$findAll,
_ref5$attribute = _ref5.attribute,
attribute = _ref5$attribute === void 0 ? null : _ref5$attribute;
// eslint-disable-next-line no-undef, no-param-reassign
attribute = attribute || _lodash["default"].get(window, 'process.env.VUE_APP_TITLE') ? 'test-id' : 'testID';
if (findAll) {

@@ -57,8 +85,2 @@ return wrapper.findAll("[".concat(attribute, "=\"").concat(testID, "\"]"));

});
}
function spyOnActionCreator(_ref3) {
var actions = _ref3.actions,
key = _ref3.key;
return jest.spyOn(actions, key).mockReturnValue(_lodash["default"].constant(_lodash["default"].noop));
}

@@ -0,1 +1,13 @@

# [0.2.0](https://github.com/lawnstarter/testing-helpers/compare/0.1.0...0.2.0) (2020-11-17)
### Bug Fixes
* **fix-window:** window ([9506c97](https://github.com/lawnstarter/testing-helpers/commit/9506c97c4111a28feeb8813bc206182462791f0c))
### Features
* **fix-window:** methods ([5256ac1](https://github.com/lawnstarter/testing-helpers/commit/5256ac10d9c2d67255ddd4c04738fb2de9d1806c))
# [0.1.0](https://github.com/lawnstarter/testing-helpers/compare/0.0.4...0.1.0) (2019-11-20)

@@ -2,0 +14,0 @@

{
"name": "testing-helpers",
"version": "0.1.0",
"version": "0.2.0",
"main": "build/index.js",

@@ -26,3 +26,3 @@ "repository": "https://github.com/lawnstarter/testing-helpers",

"@babel/preset-env": "^7.6.3",
"@commitlint/cli": "7.5.2",
"@commitlint/cli": "^9.1.2",
"@semantic-release/changelog": "3.0.4",

@@ -34,6 +34,6 @@ "@semantic-release/commit-analyzer": "6.1.0",

"@semantic-release/release-notes-generator": "7.1.4",
"commitizen": "3.0.7",
"cz-ls-commits": "https://github.com/lawnstarter/cz-ls-commits#0.3.1",
"commitizen": "^3.1.2",
"cz-ls-commits": "^1.0.4",
"eslint-config-ls-react": "https://github.com/lawnstarter/eslint-config-ls-react#3.0.0",
"husky": "3.0.1",
"husky": "^3.1.0",
"license-checker": "25.0.1",

@@ -75,3 +75,8 @@ "pretty-quick": "1.11.1",

}
},
"commitlint": {
"extends": [
"./node_modules/cz-ls-commits/commitlint"
]
}
}
# testing-helpers
[![npm version](https://badge.fury.io/js/testing-helpers.svg)](https://badge.fury.io/js/testing-helpers)
## What is this?
Shared helper methods for our frontend projects
## Troubleshooting
```
// make sure to add the following for React Native testing:
"globals": {
"window": {}
}
```
import _ from 'lodash';
// RN helpers
export function setMockYCoordinates({ inputsState, orderedInputsArray }) {

@@ -15,6 +16,23 @@ const updatedInputsState = _.cloneDeep(inputsState);

export function findTestIDInWrapper({ wrapper, testID, findAll = false }) {
// eslint-disable-next-line no-undef
const attribute = window && _.get(window, 'process.env.VUE_APP_TITLE') ? 'test-id' : 'testID';
export function spyOnActionCreator({ actions, key }) {
return jest.spyOn(actions, key).mockReturnValue(_.constant(_.noop));
}
export function removeActionCreatorSpy({ actions, key }) {
if (_.isFunction(_.get(actions, `${key}.mockRestore`))) {
actions[key].mockRestore();
}
}
export function createMockGetParamWithTestParamsReference({ testParams }) {
return (key, fallback) => {
return _.get(testParams, key, fallback);
};
}
// Shared helpers
export function findTestIDInWrapper({ wrapper, testID, findAll = false, attribute = null }) {
// eslint-disable-next-line no-undef, no-param-reassign
attribute = attribute || _.get(window, 'process.env.VUE_APP_TITLE') ? 'test-id' : 'testID';
if (findAll) {

@@ -32,5 +50,1 @@ return wrapper.findAll(`[${attribute}="${testID}"]`);

}
export function spyOnActionCreator({ actions, key }) {
return jest.spyOn(actions, key).mockReturnValue(_.constant(_.noop));
}

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