Skip to content

Commit

Permalink
chore(testing): allow skipping individual tests (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdcabrera committed Jun 14, 2022
1 parent 95ab0fb commit 6b702ee
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
"mockWindowLocation": "readonly",
"shallowHook": "readonly",
"shallowHookComponent": "readonly",
"shallowHookWrapper": "readonly"
"shallowHookWrapper": "readonly",
"skipIt": "readonly"
},
"rules": {
"arrow-parens": [
Expand Down Expand Up @@ -74,6 +75,10 @@
"import/no-named-as-default": 0,
"import/no-named-as-default-member": 0,
"jest/no-done-callback": 0,
"jest/no-standalone-expect": [
2,
{ "additionalTestBlockFunctions": ["skipIt"] }
],
"jest/prefer-to-have-length": 0,
"jsdoc/check-tag-names": [
2,
Expand Down
11 changes: 11 additions & 0 deletions config/jest.setupTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ setupDotenvFilesForEnv({ env: process.env.NODE_ENV });
*/
configure({ adapter: new Adapter() });

/**
* Conditionally skip "it" test statements.
* Ex:
* skipIt(true)('should do a thing...', () => { ... });
*
* @param {*|boolean} value Any truthy value, typically used with environment variables
*
* @returns {*|jest.It}
*/
global.skipIt = value => (value && it?.skip) || it;

/**
* Emulate for component checks
*/
Expand Down

0 comments on commit 6b702ee

Please sign in to comment.