forked from jest-community/jest-extended
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use import-all macro instead of explicit imports (jest-community#142)
- Loading branch information
1 parent
5ffe04c
commit a45463f
Showing
4 changed files
with
58 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,95 +1,5 @@ | ||
import toBeEven from './toBeEven'; | ||
import toBeTrue from './toBeTrue'; | ||
import toSatisfy from './toSatisfy'; | ||
import toBeFalse from './toBeFalse'; | ||
import toContainValue from './toContainValue'; | ||
import toContainValues from './toContainValues'; | ||
import toBeArray from './toBeArray'; | ||
import toBeArrayOfSize from './toBeArrayOfSize'; | ||
import toEqualCaseInsensitive from './toEqualCaseInsensitive'; | ||
import toStartWith from './toStartWith'; | ||
import toBeNegative from './toBeNegative'; | ||
import toBeOneOf from './toBeOneOf'; | ||
import toContainKey from './toContainKey'; | ||
import toBeString from './toBeString'; | ||
import toBeExtensible from './toBeExtensible'; | ||
import toBeWithin from './toBeWithin'; | ||
import toIncludeMultiple from './toIncludeMultiple'; | ||
import toEndWith from './toEndWith'; | ||
import toBeFrozen from './toBeFrozen'; | ||
import toBeObject from './toBeObject'; | ||
import toContainAllKeys from './toContainAllKeys'; | ||
import toContainAnyKeys from './toContainAnyKeys'; | ||
import toContainKeys from './toContainKeys'; | ||
import toBeFinite from './toBeFinite'; | ||
import toIncludeAnyMembers from './toIncludeAnyMembers'; | ||
import toIncludeAllMembers from './toIncludeAllMembers'; | ||
import toBeNaN from './toBeNaN'; | ||
import toBePositive from './toBePositive'; | ||
import toInclude from './toInclude'; | ||
import toBeBoolean from './toBeBoolean'; | ||
import toBeFunction from './toBeFunction'; | ||
import toBeNumber from './toBeNumber'; | ||
import toBeOdd from './toBeOdd'; | ||
import toContainAllValues from './toContainAllValues'; | ||
import toContainEntry from './toContainEntry'; | ||
import toContainAllEntries from './toContainAllEntries'; | ||
import toContainEntries from './toContainEntries'; | ||
import toContainAnyEntries from './toContainAnyEntries'; | ||
import toContainAnyValues from './toContainAnyValues'; | ||
import toBeNil from './toBeNil'; | ||
import toSatisfyAll from './toSatisfyAll'; | ||
import toBeEmpty from './toBeEmpty'; | ||
import toBeSealed from './toBeSealed'; | ||
import toIncludeRepeated from './toIncludeRepeated'; | ||
import toHaveBeenCalledBefore from './toHaveBeenCalledBefore'; | ||
import toBeDate from './toBeDate'; | ||
import importAll from 'import-all.macro'; | ||
|
||
export default [ | ||
toBeEven, | ||
toBeTrue, | ||
toBeFalse, | ||
toContainValue, | ||
toContainValues, | ||
toBeArray, | ||
toBeArrayOfSize, | ||
toEqualCaseInsensitive, | ||
toStartWith, | ||
toBeNegative, | ||
toBeOneOf, | ||
toContainKey, | ||
toBeExtensible, | ||
toBeString, | ||
toBeWithin, | ||
toIncludeMultiple, | ||
toEndWith, | ||
toBeFrozen, | ||
toBeObject, | ||
toContainAllKeys, | ||
toContainAnyKeys, | ||
toContainKeys, | ||
toBeFinite, | ||
toIncludeAnyMembers, | ||
toIncludeAllMembers, | ||
toBeNaN, | ||
toBePositive, | ||
toInclude, | ||
toBeBoolean, | ||
toBeFunction, | ||
toBeNumber, | ||
toBeOdd, | ||
toContainAllValues, | ||
toContainEntry, | ||
toContainAllEntries, | ||
toContainEntries, | ||
toContainAnyEntries, | ||
toContainAnyValues, | ||
toBeNil, | ||
toSatisfyAll, | ||
toBeEmpty, | ||
toBeSealed, | ||
toSatisfy, | ||
toIncludeRepeated, | ||
toHaveBeenCalledBefore, | ||
toBeDate | ||
].reduce((acc, matcher) => ({ ...acc, ...matcher }), {}); | ||
const imports = importAll.sync('./*/index.js'); | ||
|
||
export default Object.values(imports).reduce((acc, matcher) => ({ ...acc, ...matcher.default }), {}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import matchers from './index'; | ||
|
||
expect.extend(matchers); | ||
|
||
// This does not test all matchers, just couple random ones to check | ||
// if imports work correctly. | ||
|
||
describe('positive matcher', () => { | ||
test('.toBeEven', () => { | ||
expect(2).toBeEven(); | ||
}); | ||
}); | ||
|
||
describe('negative matcher', () => { | ||
test('.not.toBeWithin', () => { | ||
expect(1).not.toBeWithin(10, 20); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -438,6 +438,12 @@ babel-plugin-jest-hoist@^23.0.1: | |
version "23.0.1" | ||
resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.0.1.tgz#eaa11c964563aea9c21becef2bdf7853f7f3c148" | ||
|
||
babel-plugin-macros@^2.0.0: | ||
version "2.2.2" | ||
resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-2.2.2.tgz#049c93f4b934453688a6ec38bba529c55bf0fa1f" | ||
dependencies: | ||
cosmiconfig "^4.0.0" | ||
|
||
babel-plugin-syntax-async-functions@^6.8.0: | ||
version "6.13.0" | ||
resolved "https://registry.yarnpkg.com/babel-plugin-syntax-async-functions/-/babel-plugin-syntax-async-functions-6.13.0.tgz#cad9cad1191b5ad634bf30ae0872391e0647be95" | ||
|
@@ -951,6 +957,15 @@ cosmiconfig@^3.1.0: | |
parse-json "^3.0.0" | ||
require-from-string "^2.0.1" | ||
|
||
cosmiconfig@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-4.0.0.tgz#760391549580bbd2df1e562bc177b13c290972dc" | ||
dependencies: | ||
is-directory "^0.3.1" | ||
js-yaml "^3.9.0" | ||
parse-json "^4.0.0" | ||
require-from-string "^2.0.1" | ||
|
||
cross-spawn@^5.0.1, cross-spawn@^5.1.0: | ||
version "5.1.0" | ||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449" | ||
|
@@ -1837,6 +1852,13 @@ ignore@^3.3.3: | |
version "3.3.5" | ||
resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.5.tgz#c4e715455f6073a8d7e5dae72d2fc9d71663dba6" | ||
|
||
import-all.macro@^2.0.3: | ||
version "2.0.3" | ||
resolved "https://registry.yarnpkg.com/import-all.macro/-/import-all.macro-2.0.3.tgz#3e5de28920eb7237badb85acf15eb71c8d5b04f6" | ||
dependencies: | ||
babel-plugin-macros "^2.0.0" | ||
glob "^7.1.2" | ||
|
||
import-local@^1.0.0: | ||
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/import-local/-/import-local-1.0.0.tgz#5e4ffdc03f4fe6c009c6729beb29631c2f8227bc" | ||
|
@@ -2616,6 +2638,10 @@ jsesc@^1.3.0: | |
version "1.3.0" | ||
resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" | ||
|
||
json-parse-better-errors@^1.0.1: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" | ||
|
||
json-schema-traverse@^0.3.0: | ||
version "0.3.1" | ||
resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz#349a6d44c53a51de89b40805c5d5e59b417d3340" | ||
|
@@ -3265,6 +3291,13 @@ parse-json@^3.0.0: | |
dependencies: | ||
error-ex "^1.3.1" | ||
|
||
parse-json@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/parse-json/-/parse-json-4.0.0.tgz#be35f5425be1f7f6c747184f98a788cb99477ee0" | ||
dependencies: | ||
error-ex "^1.3.1" | ||
json-parse-better-errors "^1.0.1" | ||
|
||
[email protected]: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/parse5/-/parse5-4.0.0.tgz#6d78656e3da8d78b4ec0b906f7c08ef1dfe3f608" | ||
|