@xylabs/jest-helpers 2.12.19 → 2.12.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/index.cjs +6 -5
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +6 -13
- package/dist/browser/index.js.map +1 -1
- package/dist/browser/tags/index.cjs +6 -5
- package/dist/browser/tags/index.cjs.map +1 -1
- package/dist/browser/tags/index.d.cts.map +1 -1
- package/dist/browser/tags/index.d.mts.map +1 -1
- package/dist/browser/tags/index.d.ts.map +1 -1
- package/dist/browser/tags/index.js +6 -13
- package/dist/browser/tags/index.js.map +1 -1
- package/dist/node/index.cjs +6 -5
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +6 -13
- package/dist/node/index.js.map +1 -1
- package/dist/node/tags/index.cjs +6 -5
- package/dist/node/tags/index.cjs.map +1 -1
- package/dist/node/tags/index.d.cts.map +1 -1
- package/dist/node/tags/index.d.mts.map +1 -1
- package/dist/node/tags/index.d.ts.map +1 -1
- package/dist/node/tags/index.js +6 -13
- package/dist/node/tags/index.js.map +1 -1
- package/package.json +1 -4
- package/src/tags/index.ts +9 -7
package/dist/browser/index.cjs
CHANGED
|
@@ -83,15 +83,16 @@ var badTags = (arr) => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
// src/tags/index.ts
|
|
86
|
-
var argv = require("minimist")(process.argv.slice(2));
|
|
87
86
|
function tags(...tagLabels) {
|
|
88
|
-
const
|
|
87
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
88
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
89
|
+
const filter = matchFilter(passedTags);
|
|
89
90
|
const thisGlobal = global;
|
|
90
91
|
const chain = {};
|
|
91
92
|
const filterMatch = filter(tagLabels);
|
|
92
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
93
|
-
chain.itIf = filterMatch ? itIf :
|
|
94
|
-
chain.testIf = filterMatch ? testIf :
|
|
93
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
94
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
95
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
95
96
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
96
97
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
97
98
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './tags'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './tags'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,IAAAA,QAAO,CAACA,KAAI;AAAA,EACd;AACA,MAAI,IAAI,SAAS,SAAS,GAAG;AAC3B,UAAMC,WAAU,SAAS,IAAI,MAAM,OAAO,CAAC;AAC3C,UAAMC,WAAU,QAAQ,IAAI,MAAM,OAAO,CAAC;AAC1C,QAAIA,SAAQ,WAAW,GAAG;AACxB,aAAOD,SAA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AAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/describeIf.ts
|
|
10
2
|
var describeIf = (expr) => expr ? describe : describe.skip;
|
|
11
3
|
|
|
@@ -62,15 +54,16 @@ var badTags = (arr) => {
|
|
|
62
54
|
};
|
|
63
55
|
|
|
64
56
|
// src/tags/index.ts
|
|
65
|
-
var argv = __require("minimist")(process.argv.slice(2));
|
|
66
57
|
function tags(...tagLabels) {
|
|
67
|
-
const
|
|
58
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
59
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
60
|
+
const filter = matchFilter(passedTags);
|
|
68
61
|
const thisGlobal = global;
|
|
69
62
|
const chain = {};
|
|
70
63
|
const filterMatch = filter(tagLabels);
|
|
71
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
72
|
-
chain.itIf = filterMatch ? itIf :
|
|
73
|
-
chain.testIf = filterMatch ? testIf :
|
|
64
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
65
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
66
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
74
67
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
75
68
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
76
69
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,IAAAA,QAAO,CAACA,KAAI;AAAA,EACd;AACA,MAAI,IAAI,SAAS,SAAS,GAAG;AAC3B,UAAMC,WAAU,SAAS,IAAI,MAAM,OAAO,CAAC;AAC3C,UAA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E,QAAQ,YAAY,EAAE,CAAC;AAClF;;;ACtCO,SAAS,QAAQ,WAAqB;AAC3C,QAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
|
@@ -80,15 +80,16 @@ var badTags = (arr) => {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
// src/tags/index.ts
|
|
83
|
-
var argv = require("minimist")(process.argv.slice(2));
|
|
84
83
|
function tags(...tagLabels) {
|
|
85
|
-
const
|
|
84
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
85
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
86
|
+
const filter = matchFilter(passedTags);
|
|
86
87
|
const thisGlobal = global;
|
|
87
88
|
const chain = {};
|
|
88
89
|
const filterMatch = filter(tagLabels);
|
|
89
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
90
|
-
chain.itIf = filterMatch ? itIf :
|
|
91
|
-
chain.testIf = filterMatch ? testIf :
|
|
90
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
91
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
92
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
92
93
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
93
94
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
94
95
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tags/index.ts","../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/tags/index.ts","../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAA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/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/describeIf.ts
|
|
10
2
|
var describeIf = (expr) => expr ? describe : describe.skip;
|
|
11
3
|
|
|
@@ -62,15 +54,16 @@ var badTags = (arr) => {
|
|
|
62
54
|
};
|
|
63
55
|
|
|
64
56
|
// src/tags/index.ts
|
|
65
|
-
var argv = __require("minimist")(process.argv.slice(2));
|
|
66
57
|
function tags(...tagLabels) {
|
|
67
|
-
const
|
|
58
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
59
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
60
|
+
const filter = matchFilter(passedTags);
|
|
68
61
|
const thisGlobal = global;
|
|
69
62
|
const chain = {};
|
|
70
63
|
const filterMatch = filter(tagLabels);
|
|
71
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
72
|
-
chain.itIf = filterMatch ? itIf :
|
|
73
|
-
chain.testIf = filterMatch ? testIf :
|
|
64
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
65
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
66
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
74
67
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
75
68
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
76
69
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts","../../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts","../../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,IAAAA,QAAO,CAACA,KAAI;AAAA,EACd;AACA,MAAI,IAAI,SAAS,SAAS,GAAG;AAC3B,UAAMC,WAAU,SAAS,IAAI,MAAM,OA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AAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;;;ACtCO,SAAS,QAAQ,WAAqB;AAC3C,QAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
package/dist/node/index.cjs
CHANGED
|
@@ -83,15 +83,16 @@ var badTags = (arr) => {
|
|
|
83
83
|
};
|
|
84
84
|
|
|
85
85
|
// src/tags/index.ts
|
|
86
|
-
var argv = require("minimist")(process.argv.slice(2));
|
|
87
86
|
function tags(...tagLabels) {
|
|
88
|
-
const
|
|
87
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
88
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
89
|
+
const filter = matchFilter(passedTags);
|
|
89
90
|
const thisGlobal = global;
|
|
90
91
|
const chain = {};
|
|
91
92
|
const filterMatch = filter(tagLabels);
|
|
92
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
93
|
-
chain.itIf = filterMatch ? itIf :
|
|
94
|
-
chain.testIf = filterMatch ? testIf :
|
|
93
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
94
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
95
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
95
96
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
96
97
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
97
98
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './tags'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["export * from './describeIf'\nexport * from './itIf'\nexport * from './tags'\nexport * from './testIf'\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,IAAAA,QAAO,CAACA,KAAI;AAAA,EACd;AACA,MAAI,IAAI,SAAS,SAAS,GAAG;AAC3B,UAAMC,WAAU,SAAS,IAAI,MAAM,OAAO,CAAC;AAC3C,UAAMC,WAAU,QAAQ,IAAI,MAAM,OAAO,CAAC;AAC1C,QAAI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Q,WAAqB;AAC3C,QAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
package/dist/node/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/describeIf.ts
|
|
10
2
|
var describeIf = (expr) => expr ? describe : describe.skip;
|
|
11
3
|
|
|
@@ -62,15 +54,16 @@ var badTags = (arr) => {
|
|
|
62
54
|
};
|
|
63
55
|
|
|
64
56
|
// src/tags/index.ts
|
|
65
|
-
var argv = __require("minimist")(process.argv.slice(2));
|
|
66
57
|
function tags(...tagLabels) {
|
|
67
|
-
const
|
|
58
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
59
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
60
|
+
const filter = matchFilter(passedTags);
|
|
68
61
|
const thisGlobal = global;
|
|
69
62
|
const chain = {};
|
|
70
63
|
const filterMatch = filter(tagLabels);
|
|
71
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
72
|
-
chain.itIf = filterMatch ? itIf :
|
|
73
|
-
chain.testIf = filterMatch ? testIf :
|
|
64
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
65
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
66
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
74
67
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
75
68
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
76
69
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../src/describeIf.ts","../../src/itIf.ts","../../src/testIf.ts","../../src/tags/config.ts","../../src/tags/regexps.ts","../../src/tags/filter.ts","../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,IAAAA,QAAO,CAACA,KAAI;AAAA,EACd;AACA,MAAI,IAAI,SAAS,SAAS,GAAG;A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,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;;;ACtCO,SAAS,QAAQ,WAAqB;AAC3C,QAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
package/dist/node/tags/index.cjs
CHANGED
|
@@ -80,15 +80,16 @@ var badTags = (arr) => {
|
|
|
80
80
|
};
|
|
81
81
|
|
|
82
82
|
// src/tags/index.ts
|
|
83
|
-
var argv = require("minimist")(process.argv.slice(2));
|
|
84
83
|
function tags(...tagLabels) {
|
|
85
|
-
const
|
|
84
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
85
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
86
|
+
const filter = matchFilter(passedTags);
|
|
86
87
|
const thisGlobal = global;
|
|
87
88
|
const chain = {};
|
|
88
89
|
const filterMatch = filter(tagLabels);
|
|
89
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
90
|
-
chain.itIf = filterMatch ? itIf :
|
|
91
|
-
chain.testIf = filterMatch ? testIf :
|
|
90
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
91
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
92
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
92
93
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
93
94
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
94
95
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/tags/index.ts","../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["
|
|
1
|
+
{"version":3,"sources":["../../../src/tags/index.ts","../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts"],"sourcesContent":["import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n","/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OA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exclude"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tags/index.ts"],"names":[],"mappings":"AAOA,wBAAgB,IAAI,CAAC,GAAG,SAAS,EAAE,MAAM,EAAE,uBA0B1C"}
|
package/dist/node/tags/index.js
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
2
|
-
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
3
|
-
}) : x)(function(x) {
|
|
4
|
-
if (typeof require !== "undefined")
|
|
5
|
-
return require.apply(this, arguments);
|
|
6
|
-
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
1
|
// src/describeIf.ts
|
|
10
2
|
var describeIf = (expr) => expr ? describe : describe.skip;
|
|
11
3
|
|
|
@@ -62,15 +54,16 @@ var badTags = (arr) => {
|
|
|
62
54
|
};
|
|
63
55
|
|
|
64
56
|
// src/tags/index.ts
|
|
65
|
-
var argv = __require("minimist")(process.argv.slice(2));
|
|
66
57
|
function tags(...tagLabels) {
|
|
67
|
-
const
|
|
58
|
+
const tagsParam = process.argv.findIndex((item) => item === "--tags");
|
|
59
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : void 0;
|
|
60
|
+
const filter = matchFilter(passedTags);
|
|
68
61
|
const thisGlobal = global;
|
|
69
62
|
const chain = {};
|
|
70
63
|
const filterMatch = filter(tagLabels);
|
|
71
|
-
chain.describeIf = filterMatch ? describeIf :
|
|
72
|
-
chain.itIf = filterMatch ? itIf :
|
|
73
|
-
chain.testIf = filterMatch ? testIf :
|
|
64
|
+
chain.describeIf = filterMatch ? describeIf : (_param) => describe.skip;
|
|
65
|
+
chain.itIf = filterMatch ? itIf : (_param) => it.skip;
|
|
66
|
+
chain.testIf = filterMatch ? testIf : (_param) => test.skip;
|
|
74
67
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe;
|
|
75
68
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit;
|
|
76
69
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts","../../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","
|
|
1
|
+
{"version":3,"sources":["../../../src/describeIf.ts","../../../src/itIf.ts","../../../src/testIf.ts","../../../src/tags/config.ts","../../../src/tags/regexps.ts","../../../src/tags/filter.ts","../../../src/tags/index.ts"],"sourcesContent":["/**\n * Conditionally runs or skips the describe\n * @param expr The condition to evaluate\n * @returns If the condition is true, describe, otherwise skips\n */\nexport const describeIf = <T>(expr?: T | null) => (expr ? describe : describe.skip)\n","/**\n * Conditionally runs or skips the it\n * @param expr The condition to evaluate\n * @returns If the condition is true, it, otherwise skips\n */\nexport const itIf = <T>(expr?: T | null) => (expr ? it : it.skip)\n","/**\n * Conditionally runs or skips the test\n * @param expr The condition to evaluate\n * @returns If the condition is true, test, otherwise skips\n */\nexport const testIf = <T>(expr?: T | null) => (expr ? test : test.skip)\n","export const NOT_SYMBOL = '!'\n\nexport const AND_SYMBOL = '&&'\n\nexport const OR_SYMBOL = '||'\n\nexport const RESERVED_COMMANDS = ['--tags']\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\n\nexport const escape = (str: string) =>\n str\n .split('')\n .map((symbol) => `\\\\${symbol}`)\n .join('')\n\nexport const AND_REGX = new RegExp(`\\\\s*${escape(AND_SYMBOL)}\\\\s*`)\n\nexport const OR_REGX = new RegExp(`\\\\s*${escape(OR_SYMBOL)}\\\\s*`)\n\nexport const PLAIN_REGX = new RegExp('\\\\s+')\n\nexport const BAD_REGX = new RegExp(`^${escape(NOT_SYMBOL)}.*$`)\n\nexport const GOOD_REGX = new RegExp(`^[^${escape(NOT_SYMBOL)}].*$`)\n","import { AND_SYMBOL, NOT_SYMBOL, OR_SYMBOL } from './config'\nimport { AND_REGX, BAD_REGX, GOOD_REGX, OR_REGX, PLAIN_REGX } from './regexps'\n\n// f.e. tag1 !tag2\n// tag1 && tag2 && !tag3\n// tag1 || tag2 || !tag3\n\n//ATTENTION!!: cases with () not handled: f.e. (tag1 && tag2) || tag3 won`t work\n\nexport const matchFilter =\n (strParam = '') =>\n (tags: string[]) => {\n const str = strParam.trim()\n if (typeof tags === 'string') {\n tags = [tags]\n }\n if (str.includes(OR_SYMBOL)) {\n const include = goodTags(str.split(OR_REGX))\n const exclude = badTags(str.split(OR_REGX))\n if (exclude.length === 0) {\n return include.length === 0 || include.some((s) => tags.includes(s))\n }\n if (include.length === 0 && exclude.length !== 0) {\n return exclude.some((s) => !tags.includes(s))\n }\n return include.length === 0 || include.some((s) => tags.includes(s)) || exclude.some((s) => !tags.includes(s))\n }\n if (str.includes(AND_SYMBOL)) {\n const include = goodTags(str.split(AND_REGX))\n const exclude = badTags(str.split(AND_REGX))\n\n return (include.length === 0 || include.every((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n const include = goodTags(str.split(PLAIN_REGX))\n const exclude = badTags(str.split(PLAIN_REGX))\n\n return (include.length === 0 || include.some((s) => tags.includes(s))) && !exclude.some((s) => tags.includes(s))\n }\n\nconst goodTags = (arr: string[]) => {\n return arr.filter((s) => s.match(GOOD_REGX))\n}\n\nconst badTags = (arr: string[]) => {\n return arr.filter((s) => s.match(BAD_REGX)).map((s) => s.replace(NOT_SYMBOL, ''))\n}\n","import { describeIf } from '../describeIf'\nimport { itIf } from '../itIf'\nimport { testIf } from '../testIf'\nimport { matchFilter } from './filter'\n\n//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1\n\nexport function tags(...tagLabels: string[]) {\n const tagsParam = process.argv.findIndex((item) => item === '--tags')\n const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined\n const filter = matchFilter(passedTags)\n const thisGlobal = global\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const chain: Record<string, any> = {}\n\n const filterMatch = filter(tagLabels)\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.itIf = filterMatch ? itIf : (_param: any) => it.skip\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n chain.testIf = filterMatch ? testIf : (_param: any) => test.skip\n chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe\n chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit\n chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest\n chain.test.only = thisGlobal.test.only\n chain.test.skip = thisGlobal.test.skip\n chain.xtest = thisGlobal.xtest\n chain.xit = thisGlobal.xit\n\n return chain\n}\n"],"mappings":";AAKO,IAAM,aAAa,CAAI,SAAqB,OAAO,WAAW,SAAS;;;ACAvE,IAAM,OAAO,CAAI,SAAqB,OAAO,KAAK,GAAG;;;ACArD,IAAM,SAAS,CAAI,SAAqB,OAAO,OAAO,KAAK;;;ACL3D,IAAM,aAAa;AAEnB,IAAM,aAAa;AAEnB,IAAM,YAAY;;;ACFlB,IAAM,SAAS,CAAC,QACrB,IACG,MAAM,EAAE,EACR,IAAI,CAAC,WAAW,KAAK,MAAM,EAAE,EAC7B,KAAK,EAAE;AAEL,IAAM,WAAW,IAAI,OAAO,OAAO,OAAO,UAAU,CAAC,MAAM;AAE3D,IAAM,UAAU,IAAI,OAAO,OAAO,OAAO,SAAS,CAAC,MAAM;AAEzD,IAAM,aAAa,IAAI,OAAO,MAAM;AAEpC,IAAM,WAAW,IAAI,OAAO,IAAI,OAAO,UAAU,CAAC,KAAK;AAEvD,IAAM,YAAY,IAAI,OAAO,MAAM,OAAO,UAAU,CAAC,MAAM;;;ACP3D,IAAM,cACX,CAAC,WAAW,OACZ,CAACA,UAAmB;AAClB,QAAM,MAAM,SAAS,KAAK;AAC1B,MAAI,OAAOA,UAAS,UAAU;AAC5B,I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AC;AAC7C;AAEA,IAAM,UAAU,CAAC,QAAkB;AACjC,SAAO,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,QAAQ,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,YAAY,EAAE,CAAC;AAClF;;;ACtCO,SAAS,QAAQ,WAAqB;AAC3C,QAAM,YAAY,QAAQ,KAAK,UAAU,CAAC,SAAS,SAAS,QAAQ;AACpE,QAAM,aAAa,YAAY,IAAI,QAAQ,KAAK,YAAY,CAAC,IAAI;AACjE,QAAM,SAAS,YAAY,UAAU;AACrC,QAAM,aAAa;AAGnB,QAAM,QAA6B,CAAC;AAEpC,QAAM,cAAc,OAAO,SAAS;AAGpC,QAAM,aAAa,cAAc,aAAa,CAAC,WAAgB,SAAS;AAExE,QAAM,OAAO,cAAc,OAAO,CAAC,WAAgB,GAAG;AAEtD,QAAM,SAAS,cAAc,SAAS,CAAC,WAAgB,KAAK;AAC5D,QAAM,WAAW,cAAc,WAAW,WAAW,WAAW;AAChE,QAAM,KAAK,cAAc,WAAW,KAAK,WAAW;AACpD,QAAM,OAAO,cAAc,WAAW,OAAO,WAAW;AACxD,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,KAAK,OAAO,WAAW,KAAK;AAClC,QAAM,QAAQ,WAAW;AACzB,QAAM,MAAM,WAAW;AAEvB,SAAO;AACT;","names":["tags","include","exclude"]}
|
package/package.json
CHANGED
|
@@ -38,9 +38,6 @@
|
|
|
38
38
|
"typescript",
|
|
39
39
|
"esm"
|
|
40
40
|
],
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"minimist": "^1.2.8"
|
|
43
|
-
},
|
|
44
41
|
"devDependencies": {
|
|
45
42
|
"@xylabs/ts-scripts-yarn3": "^3.0.88",
|
|
46
43
|
"@xylabs/tsconfig": "^3.0.88",
|
|
@@ -58,6 +55,6 @@
|
|
|
58
55
|
"url": "https://github.com/xylabs/sdk-js.git"
|
|
59
56
|
},
|
|
60
57
|
"sideEffects": false,
|
|
61
|
-
"version": "2.12.
|
|
58
|
+
"version": "2.12.20",
|
|
62
59
|
"type": "module"
|
|
63
60
|
}
|
package/src/tags/index.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
2
|
-
const argv = require('minimist')(process.argv.slice(2))
|
|
3
|
-
|
|
4
1
|
import { describeIf } from '../describeIf'
|
|
5
2
|
import { itIf } from '../itIf'
|
|
6
3
|
import { testIf } from '../testIf'
|
|
@@ -9,7 +6,9 @@ import { matchFilter } from './filter'
|
|
|
9
6
|
//Based on https://www.npmjs.com/package/jest-tags/v/1.0.1
|
|
10
7
|
|
|
11
8
|
export function tags(...tagLabels: string[]) {
|
|
12
|
-
const
|
|
9
|
+
const tagsParam = process.argv.findIndex((item) => item === '--tags')
|
|
10
|
+
const passedTags = tagsParam > 0 ? process.argv[tagsParam + 1] : undefined
|
|
11
|
+
const filter = matchFilter(passedTags)
|
|
13
12
|
const thisGlobal = global
|
|
14
13
|
|
|
15
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -17,9 +16,12 @@ export function tags(...tagLabels: string[]) {
|
|
|
17
16
|
|
|
18
17
|
const filterMatch = filter(tagLabels)
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
chain.
|
|
22
|
-
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
chain.describeIf = filterMatch ? describeIf : (_param: any) => describe.skip
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
22
|
+
chain.itIf = filterMatch ? itIf : (_param: any) => it.skip
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
chain.testIf = filterMatch ? testIf : (_param: any) => test.skip
|
|
23
25
|
chain.describe = filterMatch ? thisGlobal.describe : thisGlobal.xdescribe
|
|
24
26
|
chain.it = filterMatch ? thisGlobal.it : thisGlobal.xit
|
|
25
27
|
chain.test = filterMatch ? thisGlobal.test : thisGlobal.xtest
|