test-fns 1.5.0 → 1.6.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/dist/givenWhenThen.js +3 -4
- package/dist/givenWhenThen.js.map +1 -1
- package/dist/givenWhenThen.test.js +2 -11
- package/dist/givenWhenThen.test.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/usePrep.d.ts +10 -0
- package/dist/usePrep.js +45 -0
- package/dist/usePrep.js.map +1 -0
- package/dist/usePrep.test.d.ts +1 -0
- package/dist/usePrep.test.js +63 -0
- package/dist/usePrep.test.js.map +1 -0
- package/license.md +21 -0
- package/package.json +21 -20
- package/readme.md +18 -0
package/dist/givenWhenThen.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.then = exports.when = exports.given = exports.getNumberRange = void 0;
|
|
4
|
-
const
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
5
|
const getNumberRange = (input) => {
|
|
6
6
|
// Calculate the length of the range
|
|
7
7
|
const length = input.end - input.start + 1;
|
|
@@ -11,7 +11,6 @@ const getNumberRange = (input) => {
|
|
|
11
11
|
exports.getNumberRange = getNumberRange;
|
|
12
12
|
const castToJestTestInput = ({ input, prefix, }) => {
|
|
13
13
|
const method = input.length === 3 ? input[2] : input[1]; // its always last
|
|
14
|
-
const methodWithBetterErrorLog = method;
|
|
15
14
|
if (input.length === 3)
|
|
16
15
|
return [`${prefix}: ${input[0]}`, method]; // we allow users to specify the reason for code readability, but we dont expose this in the test report to decrease noise. folks can look in the code if they want to know "why"
|
|
17
16
|
return [`${prefix}: ${input[0]}`, method]; // otherwise, its the normal input
|
|
@@ -42,7 +41,7 @@ exports.then.repeatably =
|
|
|
42
41
|
(configuration) => (...input) => {
|
|
43
42
|
// validate the input length
|
|
44
43
|
if (input.length !== 2 && input.length !== 3)
|
|
45
|
-
throw new
|
|
44
|
+
throw new helpful_errors_1.UnexpectedCodePathError('unsupported input length', {
|
|
46
45
|
input,
|
|
47
46
|
});
|
|
48
47
|
// support the "SOME" criteria
|
|
@@ -73,6 +72,6 @@ exports.then.repeatably =
|
|
|
73
72
|
return;
|
|
74
73
|
}
|
|
75
74
|
// throw if neither
|
|
76
|
-
throw new
|
|
75
|
+
throw new helpful_errors_1.UnexpectedCodePathError('configuration.criteria was neither EVERY nor SOME', { configuration });
|
|
77
76
|
};
|
|
78
77
|
//# sourceMappingURL=givenWhenThen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"givenWhenThen.js","sourceRoot":"","sources":["../src/givenWhenThen.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"givenWhenThen.js","sourceRoot":"","sources":["../src/givenWhenThen.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAElD,MAAM,cAAc,GAAG,CAAC,KAG9B,EAAY,EAAE;IACb,oCAAoC;IACpC,MAAM,MAAM,GAAG,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC;IAC3C,2CAA2C;IAC3C,OAAO,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC,CAAC;AARW,QAAA,cAAc,kBAQzB;AAcF,MAAM,mBAAmB,GAAG,CAAC,EAC3B,KAAK,EACL,MAAM,GAIP,EAAwE,EAAE;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,kBAAkB;IAC3E,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE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,KAAK,CAAC;gBACpB,IAAA,YAAI,EAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;YACxD,OAAO;QACT,CAAC;QAED,+BAA+B;QAC/B,IAAI,aAAa,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;YACvC,KAAK,MAAM,OAAO,IAAI,IAAA,sBAAc,EAAC;gBACnC,KAAK,EAAE,CAAC;gBACR,GAAG,EAAE,aAAa,CAAC,QAAQ;aAC5B,CAAC,EAAE,CAAC;gBACH,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;oBACpB,IAAA,YAAI,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,OAAO,EAAE,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;gBACvE,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;oBACpB,IAAA,YAAI,EAAC,KAAK,CAAC,CAAC,CAAC,GAAG,aAAa,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CACrD,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CACtB,CAAC;YACN,CAAC;YACD,OAAO;QACT,CAAC;QAED,mBAAmB;QACnB,MAAM,IAAI,wCAAuB,CAC/B,mDAAmD,EACnD,EAAE,aAAa,EAAE,CAClB,CAAC;IACJ,CAAC,CAAC"}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
const givenWhenThen_1 = require("./givenWhenThen");
|
|
13
4
|
const doesPlantNeedWater = (plant) => plant.hydration === 'DRY';
|
|
@@ -74,9 +65,9 @@ describe('doesPlantNeedWater', () => {
|
|
|
74
65
|
});
|
|
75
66
|
});
|
|
76
67
|
(0, givenWhenThen_1.when)('criteria = SOME', () => {
|
|
77
|
-
givenWhenThen_1.then.repeatably({ attempts: 5, criteria: 'SOME' })('it should have access to the attempt counter', ({ attempt }) =>
|
|
68
|
+
givenWhenThen_1.then.repeatably({ attempts: 5, criteria: 'SOME' })('it should have access to the attempt counter', async ({ attempt }) => {
|
|
78
69
|
expect(attempt).toBeGreaterThan(3);
|
|
79
|
-
})
|
|
70
|
+
});
|
|
80
71
|
});
|
|
81
72
|
});
|
|
82
73
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"givenWhenThen.test.js","sourceRoot":"","sources":["../src/givenWhenThen.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"givenWhenThen.test.js","sourceRoot":"","sources":["../src/givenWhenThen.test.ts"],"names":[],"mappings":";;AAAA,mDAAoD;AAGpD,MAAM,kBAAkB,GAAG,CAAC,KAAY,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,KAAK,KAAK,CAAC;AAEvE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,IAAA,qBAAK,EAAC,SAAS,EAAE,GAAG,EAAE;QACpB,IAAA,oBAAI,EAAC,oCAAoC,EAAE,GAAG,EAAE;YAC9C,MAAM,KAAK,GAAU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AAC,CAAC;YAC7B,CAAC,CACF,CAAC;YACF,oBAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CACjD,8CAA8C,EAC9C,CAAC,EAAE,OAAO,EAAE,EAAE,EAAE;gBACd,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACrC,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,IAAA,oBAAI,EAAC,iBAAiB,EAAE,GAAG,EAAE;YAC3B,oBAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAChD,8CAA8C,EAC9C,KAAK,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE;gBACpB,MAAM,CAAC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC;YACrC,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getError = exports.genTestUuid = exports.then = exports.when = exports.given = void 0;
|
|
3
|
+
exports.getError = exports.usePrep = exports.genTestUuid = exports.then = exports.when = exports.given = void 0;
|
|
4
4
|
var givenWhenThen_1 = require("./givenWhenThen");
|
|
5
5
|
Object.defineProperty(exports, "given", { enumerable: true, get: function () { return givenWhenThen_1.given; } });
|
|
6
6
|
Object.defineProperty(exports, "when", { enumerable: true, get: function () { return givenWhenThen_1.when; } });
|
|
7
7
|
Object.defineProperty(exports, "then", { enumerable: true, get: function () { return givenWhenThen_1.then; } });
|
|
8
8
|
var genTestUuid_1 = require("./genTestUuid");
|
|
9
9
|
Object.defineProperty(exports, "genTestUuid", { enumerable: true, get: function () { return genTestUuid_1.genTestUuid; } });
|
|
10
|
+
var usePrep_1 = require("./usePrep");
|
|
11
|
+
Object.defineProperty(exports, "usePrep", { enumerable: true, get: function () { return usePrep_1.usePrep; } });
|
|
10
12
|
// forward the getError method since it is almost always needed with tests
|
|
11
|
-
var
|
|
12
|
-
Object.defineProperty(exports, "getError", { enumerable: true, get: function () { return
|
|
13
|
+
var helpful_errors_1 = require("helpful-errors");
|
|
14
|
+
Object.defineProperty(exports, "getError", { enumerable: true, get: function () { return helpful_errors_1.getError; } });
|
|
13
15
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAA3C,sGAAA,KAAK,OAAA;AAAE,qGAAA,IAAI,OAAA;AAAE,qGAAA,IAAI,OAAA;AAC1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAoD;AAA3C,sGAAA,KAAK,OAAA;AAAE,qGAAA,IAAI,OAAA;AAAE,qGAAA,IAAI,OAAA;AAC1B,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,0EAA0E;AAC1E,iDAA0C;AAAjC,0GAAA,QAAQ,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* .what = declare a resource to be prepared before tests
|
|
3
|
+
* .why = simplifies devexp by letting you write `const thing = usePrep(...)`
|
|
4
|
+
* .mode =
|
|
5
|
+
* - 'beforeAll': prepare once for all tests
|
|
6
|
+
* - 'beforeEach': prepare fresh for each test run
|
|
7
|
+
*/
|
|
8
|
+
export declare const usePrep: <T extends Record<string, any>>(setup: () => Promise<T>, options?: {
|
|
9
|
+
mode: 'beforeAll' | 'beforeEach';
|
|
10
|
+
}) => T;
|
package/dist/usePrep.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.usePrep = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = declare a resource to be prepared before tests
|
|
7
|
+
* .why = simplifies devexp by letting you write `const thing = usePrep(...)`
|
|
8
|
+
* .mode =
|
|
9
|
+
* - 'beforeAll': prepare once for all tests
|
|
10
|
+
* - 'beforeEach': prepare fresh for each test run
|
|
11
|
+
*/
|
|
12
|
+
const usePrep = (setup, options = { mode: 'beforeAll' }) => {
|
|
13
|
+
// metaphor: "drawer" = proxy target, "toolbox" = real resolved resource
|
|
14
|
+
const drawer = {}; // exposed object users access
|
|
15
|
+
let toolbox; // holds the resolved result of setup()
|
|
16
|
+
// declare proxy handler up front so we can mutate it
|
|
17
|
+
const proxyHandler = {
|
|
18
|
+
get(_, prop) {
|
|
19
|
+
if (toolbox === undefined)
|
|
20
|
+
throw new helpful_errors_1.UnexpectedCodePathError('usePrep: tried to access value before setup completed');
|
|
21
|
+
return toolbox[prop];
|
|
22
|
+
},
|
|
23
|
+
ownKeys() {
|
|
24
|
+
return Reflect.ownKeys(drawer);
|
|
25
|
+
},
|
|
26
|
+
getOwnPropertyDescriptor(_, prop) {
|
|
27
|
+
return Object.getOwnPropertyDescriptor(drawer, prop);
|
|
28
|
+
},
|
|
29
|
+
apply() {
|
|
30
|
+
throw new Error('usePrep: value is not callable');
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
const register = options.mode === 'beforeEach' ? beforeEach : beforeAll;
|
|
34
|
+
register(async () => {
|
|
35
|
+
toolbox = await setup();
|
|
36
|
+
// assign properties from toolbox to drawer so Object.keys(), for..in, etc work
|
|
37
|
+
Object.assign(drawer, toolbox);
|
|
38
|
+
// remove get trap once setup is complete — access becomes direct
|
|
39
|
+
delete proxyHandler.get;
|
|
40
|
+
});
|
|
41
|
+
// return a proxy that looks and feels like toolbox
|
|
42
|
+
return new Proxy(drawer, proxyHandler);
|
|
43
|
+
};
|
|
44
|
+
exports.usePrep = usePrep;
|
|
45
|
+
//# sourceMappingURL=usePrep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrep.js","sourceRoot":"","sources":["../src/usePrep.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAEzD;;;;;;GAMG;AACI,MAAM,OAAO,GAAG,CACrB,KAAuB,EACvB,UAEI,EAAE,IAAI,EAAE,WAAW,EAAE,EACtB,EAAE;IACL,wEAAwE;IACxE,MAAM,MAAM,GAAe,EAAE,CAAC,CAAC,8BAA8B;IAC7D,IAAI,OAAsB,CAAC,CAAC,uCAAuC;IAEnE,qDAAqD;IACrD,MAAM,YAAY,GAAsB;QACtC,GAAG,CAAC,CAAC,EAAE,IAAI;YACT,IAAI,OAAO,KAAK,SAAS;gBACvB,MAAM,IAAI,wCAAuB,CAC/B,uDAAuD,CACxD,CAAC;YACJ,OAAQ,OAAe,CAAC,IAAI,CAAC,CAAC;QAChC,CAAC;QACD,OAAO;YACL,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACjC,CAAC;QACD,wBAAwB,CAAC,CAAC,EAAE,IAAI;YAC9B,OAAO,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACvD,CAAC;QACD,KAAK;YACH,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;IAExE,QAAQ,CAAC,KAAK,IAAI,EAAE;QAClB,OAAO,GAAG,MAAM,KAAK,EAAE,CAAC;QAExB,+EAA+E;QAC/E,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAE/B,iEAAiE;QACjE,OAAO,YAAY,CAAC,GAAG,CAAC;IAC1B,CAAC,CAAC,CAAC;IAEH,mDAAmD;IACnD,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,YAAY,CAAM,CAAC;AAC9C,CAAC,CAAC;AA5CW,QAAA,OAAO,WA4ClB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
4
|
+
const givenWhenThen_1 = require("./givenWhenThen");
|
|
5
|
+
const usePrep_1 = require("./usePrep");
|
|
6
|
+
let callCount = 0;
|
|
7
|
+
describe('usePrep', () => {
|
|
8
|
+
(0, givenWhenThen_1.given)('a setup function that returns a test object', () => {
|
|
9
|
+
const setup = async () => {
|
|
10
|
+
callCount++;
|
|
11
|
+
return { value: `hello-${callCount}` };
|
|
12
|
+
};
|
|
13
|
+
describe('mode: beforeAll', () => {
|
|
14
|
+
(0, givenWhenThen_1.when)('registered with usePrep', () => {
|
|
15
|
+
const result = (0, usePrep_1.usePrep)(setup, { mode: 'beforeAll' });
|
|
16
|
+
(0, givenWhenThen_1.then)('value should be resolved once before all tests', async () => {
|
|
17
|
+
expect(result.value).toBeDefined();
|
|
18
|
+
expect(result.value).toMatch(/hello-1/);
|
|
19
|
+
});
|
|
20
|
+
(0, givenWhenThen_1.then)('subsequent tests still see the same value', async () => {
|
|
21
|
+
expect(result.value).toBe(`hello-1`);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe('mode: beforeEach', () => {
|
|
26
|
+
(0, givenWhenThen_1.when)('registered with usePrep', () => {
|
|
27
|
+
const capturedValues = [];
|
|
28
|
+
const result = (0, usePrep_1.usePrep)(setup, { mode: 'beforeEach' });
|
|
29
|
+
(0, givenWhenThen_1.then)('each test gets a fresh value', async () => {
|
|
30
|
+
capturedValues.push(result.value);
|
|
31
|
+
expect(result.value).toMatch(/hello-\d+/);
|
|
32
|
+
});
|
|
33
|
+
(0, givenWhenThen_1.then)('value is recomputed between tests', async () => {
|
|
34
|
+
capturedValues.push(result.value);
|
|
35
|
+
expect(new Set(capturedValues).size).toBeGreaterThan(1);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
(0, givenWhenThen_1.given)('accessing the proxy too early', () => {
|
|
41
|
+
(0, givenWhenThen_1.when)('getting a property before beforeAll runs', () => {
|
|
42
|
+
const value = (0, usePrep_1.usePrep)(async () => ({ foo: 'bar' }), {
|
|
43
|
+
mode: 'beforeAll',
|
|
44
|
+
});
|
|
45
|
+
const err = (0, helpful_errors_1.getError)(() => value.foo);
|
|
46
|
+
(0, givenWhenThen_1.then)('it throws an error', async () => {
|
|
47
|
+
expect(err.message).toMatch(/before setup completed/);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
(0, givenWhenThen_1.given)('return value is accidentally called as function', () => {
|
|
52
|
+
(0, givenWhenThen_1.when)('accessing as if it were a callable', () => {
|
|
53
|
+
const value = (0, usePrep_1.usePrep)(async () => ({ foo: 'bar' }), {
|
|
54
|
+
mode: 'beforeAll',
|
|
55
|
+
});
|
|
56
|
+
const err = (0, helpful_errors_1.getError)(() => value());
|
|
57
|
+
(0, givenWhenThen_1.then)('it throws an error', async () => {
|
|
58
|
+
expect(err.message).toMatch(/value is not a function/);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
//# sourceMappingURL=usePrep.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePrep.test.js","sourceRoot":"","sources":["../src/usePrep.test.ts"],"names":[],"mappings":";;AAAA,mDAA0C;AAE1C,mDAAoD;A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AG,EAAE,KAAK,EAAE,CAAC,EAAE;gBAClD,IAAI,EAAE,WAAW;aAClB,CAAC,CAAC;YACH,MAAM,GAAG,GAAG,IAAA,yBAAQ,EAAC,GAAG,EAAE,CAAE,KAAa,EAAE,CAAC,CAAC;YAE7C,IAAA,oBAAI,EAAC,oBAAoB,EAAE,KAAK,IAAI,EAAE;gBACpC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,yBAAyB,CAAC,CAAC;YACzD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ehmpathy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "test-fns",
|
|
3
3
|
"author": "ehmpathy",
|
|
4
4
|
"description": "write usecase driven tests systematically for simpler, safer, and more readable code",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.6.0",
|
|
6
6
|
"repository": "ehmpathy/test-fns",
|
|
7
7
|
"homepage": "https://github.com/ehmpathy/test-fns",
|
|
8
8
|
"keywords": [
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"behavior"
|
|
15
15
|
],
|
|
16
16
|
"bugs": "https://github.com/ehmpathy/test-fns/issues",
|
|
17
|
+
"license": "MIT",
|
|
17
18
|
"main": "dist/index.js",
|
|
18
19
|
"engines": {
|
|
19
20
|
"node": ">=8.0.0"
|
|
@@ -37,8 +38,8 @@
|
|
|
37
38
|
"test:lint:deps": "npx depcheck -c ./depcheckrc.yml",
|
|
38
39
|
"test:lint:eslint": "eslint -c ./.eslintrc.js src/**/*.ts",
|
|
39
40
|
"test:lint": "npm run test:lint:eslint && npm run test:lint:deps",
|
|
40
|
-
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests",
|
|
41
|
-
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests",
|
|
41
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
42
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main')",
|
|
42
43
|
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
43
44
|
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
44
45
|
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests",
|
|
@@ -46,42 +47,42 @@
|
|
|
46
47
|
"prepublish": "npm run build",
|
|
47
48
|
"preversion": "npm run prepush",
|
|
48
49
|
"postversion": "git push origin HEAD --tags --no-verify",
|
|
49
|
-
"postinstall": "[ -d .git ] &&
|
|
50
|
+
"postinstall": "[ -d .git ] && npm run prepare:husky || exit 0",
|
|
51
|
+
"prepare:husky": "npx husky install && chmod ug+x .husky/*"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"helpful-errors": "1.3.8",
|
|
55
|
+
"uuid": "10.0.0"
|
|
50
56
|
},
|
|
51
57
|
"devDependencies": {
|
|
52
|
-
"@commitlint/cli": "
|
|
58
|
+
"@commitlint/cli": "19.3.0",
|
|
53
59
|
"@commitlint/config-conventional": "13.1.0",
|
|
54
|
-
"@trivago/prettier-plugin-sort-imports": "
|
|
60
|
+
"@trivago/prettier-plugin-sort-imports": "4.3.0",
|
|
55
61
|
"@tsconfig/node-lts-strictest": "18.12.1",
|
|
56
62
|
"@types/jest": "29.2.4",
|
|
57
63
|
"@types/uuid": "10.0.0",
|
|
58
|
-
"@typescript-eslint/eslint-plugin": "
|
|
59
|
-
"@typescript-eslint/parser": "
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "7.8.0",
|
|
65
|
+
"@typescript-eslint/parser": "7.8.0",
|
|
60
66
|
"core-js": "3.26.1",
|
|
61
67
|
"cz-conventional-changelog": "3.3.0",
|
|
62
|
-
"declapract": "0.
|
|
63
|
-
"declapract-typescript-ehmpathy": "0.
|
|
68
|
+
"declapract": "0.12.3",
|
|
69
|
+
"declapract-typescript-ehmpathy": "0.39.9",
|
|
64
70
|
"depcheck": "1.4.3",
|
|
65
|
-
"eslint": "8.
|
|
66
|
-
"eslint-config-airbnb-typescript": "
|
|
71
|
+
"eslint": "8.56.0",
|
|
72
|
+
"eslint-config-airbnb-typescript": "18.0.0",
|
|
67
73
|
"eslint-config-prettier": "8.5.0",
|
|
68
74
|
"eslint-plugin-import": "2.26.0",
|
|
69
75
|
"eslint-plugin-prettier": "4.2.1",
|
|
70
76
|
"husky": "8.0.3",
|
|
71
77
|
"jest": "29.3.1",
|
|
72
78
|
"prettier": "2.8.1",
|
|
73
|
-
"ts-jest": "29.
|
|
74
|
-
"ts-node": "10.9.
|
|
75
|
-
"typescript": "4.
|
|
79
|
+
"ts-jest": "29.1.3",
|
|
80
|
+
"ts-node": "10.9.2",
|
|
81
|
+
"typescript": "5.4.5"
|
|
76
82
|
},
|
|
77
83
|
"config": {
|
|
78
84
|
"commitizen": {
|
|
79
85
|
"path": "./node_modules/cz-conventional-changelog"
|
|
80
86
|
}
|
|
81
|
-
},
|
|
82
|
-
"license": "MIT",
|
|
83
|
-
"dependencies": {
|
|
84
|
-
"@ehmpathy/error-fns": "1.3.1",
|
|
85
|
-
"uuid": "10.0.0"
|
|
86
87
|
}
|
|
87
88
|
}
|
package/readme.md
CHANGED
|
@@ -67,3 +67,21 @@ describe('your test', () => {
|
|
|
67
67
|
})
|
|
68
68
|
})
|
|
69
69
|
```
|
|
70
|
+
|
|
71
|
+
### usePrep
|
|
72
|
+
|
|
73
|
+
prepare test scenarios within a .given/.when block asynchronously, without any `let`s or `beforeAll`s
|
|
74
|
+
|
|
75
|
+
```ts
|
|
76
|
+
given('an overdue invoice', () => {
|
|
77
|
+
const invoice = usePrep(async () => {
|
|
78
|
+
const invoiceOverdue = await ... // your logic
|
|
79
|
+
return invoiceOverdue;
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
then('it should invoke a reminder', async () => {
|
|
83
|
+
const result = await nurtureInvoice({ invoice }, context)
|
|
84
|
+
expect(result.sent.reminder).toEqual(true)
|
|
85
|
+
})
|
|
86
|
+
})
|
|
87
|
+
```
|