assert-logic 1.0.0 → 1.2.0

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/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  ![Downloads](https://img.shields.io/npm/dw/assert-logic?style=flat-square) ![Version@npm](https://img.shields.io/npm/v/assert-logic?label=version%40npm&style=flat-square) ![Version@git](https://img.shields.io/github/package-json/v/szikszail/assert-logic/main?label=version%40git&style=flat-square) ![CI](https://img.shields.io/github/actions/workflow/status/szikszail/assert-logic/ci.yml?branch=main&label=ci&style=flat-square) ![Docs](https://img.shields.io/github/actions/workflow/status/szikszail/assert-logic/docs.yml?branch=main&label=docs&style=flat-square)
4
4
 
5
- This handy tool can be used to implement additional logic into your assertions, either using Chai, Jest, Assert, or
6
- plain JavaScript.
5
+ This handy tool can be used to implement additional logic into your assertions, either using Chai, Jest, Assert, or plain JavaScript.
7
6
 
8
7
  ## Usage
9
8
 
@@ -50,8 +49,10 @@ In all other cases, the value is considered passed.
50
49
 
51
50
  ### Operations
52
51
 
53
- The API contains the following functions: `and`, `or`, `not`, `xor`, `nand`, `nor`, `xnor`, and also the `evaluate`
54
- function. All accept any number of sync/async functions, Promises, or values as arguments.
52
+ The API contains the following functions: `and`, `or`, `not`, `xor`, `nand`, `nor`, `xnor`, `every`, `some`, and also the `evaluate`
53
+ function.
54
+
55
+ The following ones accept any number of sync/async functions, Promises, or values as arguments.
55
56
 
56
57
  | Operation | Description |
57
58
  |-----------|---------------------------------------------------------|
@@ -63,6 +64,23 @@ function. All accept any number of sync/async functions, Promises, or values as
63
64
  | nor | Passes if all of its arguments fail |
64
65
  | xnor | Passes if all of its arguments pass or all of them fail |
65
66
 
67
+ The `every` and `some` functions are used to evaluate an array of values. The values must be the first parameter, but both functions accept a second parameter that is a function that will be called with each value. If the function is not passed as the second parameter, the value will be interpreted as boolean values.
68
+
69
+ The `every` function is a shorthand for `and` with the values as arguments, while the `some` function is a shorthand for `or` with the values as arguments.
70
+
71
+ ```javascript
72
+ const {every, some} = require('assert-logic');
73
+ const {expect} = require('expect');
74
+
75
+ const items = [{id: 1, name: 'Item 1', price: 10}, {id: 2, name: 'Item 2', price: -20}, /* ... */];
76
+ every(items, item => {
77
+ expect(item.id, "Item should have ID as positive number").toBeGreaterThan(0);
78
+ }).evaluate(); // will not throw
79
+ some(items, item => {
80
+ expect(item.price, "Item should have a positive price").toBeGreaterThan(0);
81
+ }).evaluate(); // will throw
82
+ ```
83
+
66
84
  #### Append
67
85
 
68
86
  The `append` function can be used to append additional logic to an existing variadic logic (all except `pass`).
@@ -1 +1 @@
1
- {"version":3,"file":"and.js","sourceRoot":"","sources":["../../src/assertion/and.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,YAAa,SAAQ,4BAAiB;IACjD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,KAAK,EAAE,mDAAmD,EAAE,GAAG,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,oCAWC"}
1
+ {"version":3,"file":"and.js","sourceRoot":"","sources":["../../src/assertion/and.ts"],"names":[],"mappings":";;;AAEA,yCAA+C;AAE/C,MAAa,YAAa,SAAQ,4BAAiB;IACjD,YAAY,GAAG,MAAsC;QACnD,KAAK,CACH,KAAK,EACL,mDAAmD,EACnD,GAAG,MAAM,CACV,CAAC;IACJ,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAfD,oCAeC"}
@@ -10,7 +10,7 @@ class Assertion {
10
10
  evaluate() {
11
11
  // pass
12
12
  }
13
- // @ts-ignore
13
+ // @ts-expect-error Unused argument, intentionally
14
14
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
15
  onEvaluation(results) {
16
16
  // pass
@@ -1 +1 @@
1
- {"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../src/assertion/assertion.ts"],"names":[],"mappings":";;;AAAA,oCAAwC;AAGxC,MAAa,SAAS;IACpB,YACqB,QAAgB,EAChB,WAAmB;QADnB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,gBAAW,GAAX,WAAW,CAAQ;IAExC,CAAC;IAED,QAAQ;QACN,OAAO;IACT,CAAC;IAED,aAAa;IACb,6DAA6D;IAC7D,YAAY,CAAC,OAA2B;QACtC,OAAO;IACT,CAAC;IAES,IAAI,CAAC,OAA2B;QACxC,MAAM,IAAI,sBAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CACF;AApBD,8BAoBC"}
1
+ {"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../src/assertion/assertion.ts"],"names":[],"mappings":";;;AAAA,oCAA0C;AAG1C,MAAa,SAAS;IACpB,YACqB,QAAgB,EAChB,WAAmB;QADnB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,gBAAW,GAAX,WAAW,CAAQ;IACrC,CAAC;IAEJ,QAAQ;QACN,OAAO;IACT,CAAC;IAED,kDAAkD;IAClD,6DAA6D;IAC7D,YAAY,CAAC,OAA2B;QACtC,OAAO;IACT,CAAC;IAES,IAAI,CAAC,OAA2B;QACxC,MAAM,IAAI,sBAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CACF;AAnBD,8BAmBC"}
@@ -0,0 +1,5 @@
1
+ import { ANDAssertion } from "./and";
2
+ import type { AssertionGeneratorFunction } from "../types";
3
+ export declare class EVERYAssertion<T> extends ANDAssertion {
4
+ constructor(items: T[], fn: AssertionGeneratorFunction<T>);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EVERYAssertion = void 0;
4
+ const and_1 = require("./and");
5
+ class EVERYAssertion extends and_1.ANDAssertion {
6
+ constructor(items, fn) {
7
+ super(...(items ? items.map((item) => () => (fn || Boolean)(item)) : []));
8
+ }
9
+ }
10
+ exports.EVERYAssertion = EVERYAssertion;
11
+ //# sourceMappingURL=every.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.js","sourceRoot":"","sources":["../../src/assertion/every.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AAGnC,MAAa,cAAkB,SAAQ,kBAAY;IAC/C,YAAY,KAAU,EAAE,EAAiC;QACrD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;CACJ;AAJD,wCAIC"}
package/assertion/pass.js CHANGED
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PASSAssertion = exports.valueToString = void 0;
3
+ exports.PASSAssertion = void 0;
4
+ exports.valueToString = valueToString;
4
5
  const assertion_1 = require("./assertion");
5
6
  const error_1 = require("../error");
6
7
  function valueToString(value) {
@@ -19,7 +20,6 @@ function valueToString(value) {
19
20
  }
20
21
  return `(${typeof value} ${String(value)})`;
21
22
  }
22
- exports.valueToString = valueToString;
23
23
  class PASSAssertion extends assertion_1.Assertion {
24
24
  constructor(value) {
25
25
  super("PASS", "Expected expression to pass.");
@@ -1 +1 @@
1
- {"version":3,"file":"pass.js","sourceRoot":"","sources":["../../src/assertion/pass.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAEtC,oCAA8C;AAE9C,SAAgB,aAAa,CAAC,KAAqB;IACjD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACrB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC;QACnC,CAAC;QACD,OAAO,aAAa,IAAI,GAAG,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,OAAO,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAA;AAC7C,CAAC;AAfD,sCAeC;AAED,MAAa,aAAc,SAAQ,qBAAS;IAC1C,YAAoB,KAAqB;QACvC,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;QAD5B,UAAK,GAAL,KAAK,CAAgB;QAGvC,IAAI,KAAK,YAAY,qBAAS,EAAE,CAAC;YAC/B,OAAO,KAAsB,CAAC;QAChC,CAAC;IACH,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,MAAM,YAAY,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAM,GAAG,MA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AC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,4BAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF;AAnCD,sCAmCC"}
@@ -0,0 +1,5 @@
1
+ import { ORAssertion } from "./or";
2
+ import type { AssertionGeneratorFunction } from "../types";
3
+ export declare class SOMEAssertion<T> extends ORAssertion {
4
+ constructor(items: T[], fn: AssertionGeneratorFunction<T>);
5
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SOMEAssertion = void 0;
4
+ const or_1 = require("./or");
5
+ class SOMEAssertion extends or_1.ORAssertion {
6
+ constructor(items, fn) {
7
+ super(...(items ? items.map((item) => () => (fn || Boolean)(item)) : []));
8
+ }
9
+ }
10
+ exports.SOMEAssertion = SOMEAssertion;
11
+ //# sourceMappingURL=some.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"some.js","sourceRoot":"","sources":["../../src/assertion/some.ts"],"names":[],"mappings":";;;AAAA,6BAAiC;AAGjC,MAAa,aAAiB,SAAQ,gBAAW;IAC7C,YAAY,KAAU,EAAE,EAAiC;QACrD,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,IAAI,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC9E,CAAC;CACJ;AAJD,sCAIC"}
package/error.js CHANGED
@@ -15,7 +15,7 @@ function getErrorRepresentation(operator, expectation, assertion, results) {
15
15
  if (result instanceof Error) {
16
16
  return {
17
17
  // eslint-disable-next-line no-control-regex
18
- Error: result.message.replace(/\u001b\[\d+m/g, ''),
18
+ Error: result.message.replace(/\u001b\[\d+m/g, ""),
19
19
  };
20
20
  }
21
21
  return "Pass";
@@ -30,7 +30,7 @@ class AssertionError extends Error {
30
30
  indent: 2,
31
31
  // defaultStringType: "PLAIN",
32
32
  // defaultKeyType: "PLAIN",
33
- collectionStyle: 'block',
33
+ collectionStyle: "block",
34
34
  // lineWidth: 0,
35
35
  // blockQuote: true,
36
36
  doubleQuotedMinMultiLineLength: Infinity,
package/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B,2CAA+C;AAI/C,SAAS,sBAAsB,CAAC,QAAgB,EAAE,WAAmB,EAAE,SAAoB,EAAE,OAA4B;IACvH,MAAM,IAAI,GAAc;QACtB,CAAC,mBAAmB,QAAQ,GAAG,CAAC,EAAE,WAAW;KAC9C,CAAC;IACF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,IAAG,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,IAAI,MAAM,YAAY,cAAc,EAAE,CAAC;gBACrC,OAAO,sBAAsB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACvG,CAAC;YACD,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;gBAC5B,OAAO;oBACL,4CAA4C;oBAC5C,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;iBACnD,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvC,OAAO,IA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;AALD,oDAKC"}
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AssertionValue } from "./types";
1
+ import type { AssertionValue, AssertionGeneratorFunction } from "./types";
2
2
  import { PASSAssertion } from "./assertion/pass";
3
3
  import { NOTAssertion } from "./assertion/not";
4
4
  import { ORAssertion } from "./assertion/or";
@@ -7,6 +7,8 @@ import { XORAssertion } from "./assertion/xor";
7
7
  import { NORAssertion } from "./assertion/nor";
8
8
  import { NANDAssertion } from "./assertion/nand";
9
9
  import { XNORAssertion } from "./assertion/xnor";
10
+ import { EVERYAssertion } from "./assertion/every";
11
+ import { SOMEAssertion } from "./assertion/some";
10
12
  export declare const pass: (value: AssertionValue) => PASSAssertion;
11
13
  export declare const not: (value: AssertionValue) => NOTAssertion;
12
14
  export declare const or: (...values: AssertionValue[]) => ORAssertion;
@@ -15,3 +17,5 @@ export declare const nor: (...values: AssertionValue[]) => NORAssertion;
15
17
  export declare const nand: (...values: AssertionValue[]) => NANDAssertion;
16
18
  export declare const xor: (...values: AssertionValue[]) => XORAssertion;
17
19
  export declare const xnor: (...values: AssertionValue[]) => XNORAssertion;
20
+ export declare const every: <T>(items: T[], fn?: AssertionGeneratorFunction<T>) => EVERYAssertion<T>;
21
+ export declare const some: <T>(items: T[], fn?: AssertionGeneratorFunction<T>) => SOMEAssertion<T>;
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // import debug = require("debug");
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.xnor = exports.xor = exports.nand = exports.nor = exports.and = exports.or = exports.not = exports.pass = void 0;
4
+ exports.some = exports.every = exports.xnor = exports.xor = exports.nand = exports.nor = exports.and = exports.or = exports.not = exports.pass = void 0;
5
5
  const pass_1 = require("./assertion/pass");
6
6
  const not_1 = require("./assertion/not");
7
7
  const or_1 = require("./assertion/or");
@@ -10,13 +10,15 @@ const xor_1 = require("./assertion/xor");
10
10
  const nor_1 = require("./assertion/nor");
11
11
  const nand_1 = require("./assertion/nand");
12
12
  const xnor_1 = require("./assertion/xnor");
13
+ const every_1 = require("./assertion/every");
14
+ const some_1 = require("./assertion/some");
13
15
  const lines_builder_1 = require("lines-builder");
14
16
  (0, lines_builder_1.setDefaultOptions)({
15
17
  // Need to force EOL to be Unix style, because Windows style is not supported by YAML
16
18
  eol: "\n",
17
19
  trimLeft: false,
18
20
  skipFirstLevelIndent: true,
19
- indent: 2
21
+ indent: 2,
20
22
  });
21
23
  const pass = (value) => new pass_1.PASSAssertion(value);
22
24
  exports.pass = pass;
@@ -34,4 +36,8 @@ const xor = (...values) => new xor_1.XORAssertion(...values);
34
36
  exports.xor = xor;
35
37
  const xnor = (...values) => new xnor_1.XNORAssertion(...values);
36
38
  exports.xnor = xnor;
39
+ const every = (items, fn) => new every_1.EVERYAssertion(items, fn);
40
+ exports.every = every;
41
+ const some = (items, fn) => new some_1.SOMEAssertion(items, fn);
42
+ exports.some = some;
37
43
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,mCAAmC;;;AAKnC,2CAA+C;AAC/C,yCAA6C;AAC7C,uCAA2C;AAC3C,yCAA6C;AAC7C,yCAA6C;AAC7C,yCAA6C;AAC7C,2CAA+C;AAC/C,2CAA+C;AAE/C,iDAAgD;AAEhD,IAAA,iCAAiB,EAAC;IAChB,qFAAqF;IACrF,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,KAAK;IACf,oBAAoB,EAAE,IAAI;IAC1B,MAAM,EAAE,CAAC;CACV,CAAC,CAAC;AAEI,MAAM,IAAI,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,IAAI,oBAAa,CAAC,KAAK,CAAC,CAAC;AAA3D,QAAA,IAAI,QAAuD;AACjE,MAAM,GAAG,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,IAAI,kBAAY,CAAC,KAAK,CAAC,CAAC;AAAzD,QAAA,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AE,CAAC,CAAC;AADlB,QAAA,IAAI,QACc"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "assert-logic",
3
- "version": "1.0.0",
3
+ "version": "1.2.0",
4
4
  "description": "This repository/project is a template/placeholder for new NPM packages.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -34,63 +34,28 @@
34
34
  },
35
35
  "homepage": "https://github.com/szikszail/assert-logic#readme",
36
36
  "devDependencies": {
37
- "@types/chai": "^4.2.21",
37
+ "@eslint/js": "^9.0.0",
38
+ "@types/chai": "^5.2.3",
38
39
  "@types/debug": "^4.1.12",
39
- "@types/jest": "^29.5.12",
40
+ "@types/jest": "^30.0.0",
40
41
  "@types/js-yaml": "^4.0.9",
41
- "@types/node": "^20.11.20",
42
- "@typescript-eslint/eslint-plugin": "^7.0.2",
43
- "@typescript-eslint/parser": "^7.0.2",
44
- "chai": "^4.3.4",
42
+ "@types/node": "^25.2.2",
43
+ "chai": "^6.2.2",
45
44
  "copyfiles": "^2.4.1",
46
45
  "dotenv-ng": "^1.3.0",
47
- "eslint": "^8.57.0",
48
- "jest": "^29.7.0",
46
+ "eslint": "^9.39.2",
47
+ "globals": "^17.3.0",
48
+ "jest": "^30.0.0",
49
49
  "jest-junit": "^16.0.0",
50
- "rimraf": "^5.0.5",
50
+ "rimraf": "^6.1.2",
51
51
  "ts-jest": "^29.1.2",
52
- "typedoc": "^0.25.9",
53
- "typescript": "^5.3.3"
52
+ "typedoc": "^0.28.16",
53
+ "typescript": "^5.9.3",
54
+ "typescript-eslint": "^8.54.0"
54
55
  },
55
56
  "dependencies": {
56
57
  "debug": "^4.3.4",
57
58
  "lines-builder": "^1.5.1",
58
59
  "yaml": "^2.4.0"
59
- },
60
- "jest": {
61
- "reporters": [
62
- "default",
63
- "jest-junit"
64
- ],
65
- "transform": {
66
- "^.+\\.ts?$": "ts-jest"
67
- },
68
- "testEnvironment": "node",
69
- "testMatch": [
70
- "**/tests/**/*.test.ts"
71
- ],
72
- "testPathIgnorePatterns": [
73
- "/node_modules/",
74
- "dist"
75
- ],
76
- "setupFilesAfterEnv": [
77
- "./tests/setup/areStringsMatch.ts"
78
- ],
79
- "coverageDirectory": "./coverage",
80
- "collectCoverageFrom": [
81
- "./src/**/*.ts"
82
- ],
83
- "moduleFileExtensions": [
84
- "ts",
85
- "js"
86
- ],
87
- "coverageThreshold": {
88
- "global": {
89
- "branches": 85,
90
- "functions": 85,
91
- "lines": 85,
92
- "statements": 85
93
- }
94
- }
95
60
  }
96
61
  }