@bemedev/dev-utils 1.0.0 → 1.0.2
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 +34 -14
- package/lib/build-tests/addTarball.d.ts +1 -1
- package/lib/build-tests/buildPackageJson.d.ts +3 -3
- package/lib/build-tests/cleanup.d.ts +1 -1
- package/lib/build-tests/cli/cli.d.ts +51 -1
- package/lib/build-tests/cli/index.d.ts +1 -0
- package/lib/build-tests/cli/post.d.ts +5 -1
- package/lib/build-tests/cli/pre.d.ts +5 -1
- package/lib/build-tests/cli/test.d.ts +15 -1
- package/lib/build-tests/constants.d.ts +1 -1
- package/lib/build-tests/getRelativePath.d.ts +1 -1
- package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
- package/lib/build-tests/import.d.ts +2 -2
- package/lib/build-tests/imports/create.d.ts +3 -3
- package/lib/build-tests/imports/helper.d.ts +7 -3
- package/lib/build-tests/imports/index.d.ts +1 -1
- package/lib/build-tests/index.d.ts +5 -5
- package/lib/build-tests/pack.d.ts +1 -1
- package/lib/rolldown-config/config.d.ts +1 -1
- package/lib/rolldown-config/constants.d.ts +5 -5
- package/lib/rolldown-config/helpers.d.ts +2 -2
- package/lib/rolldown-config/index.d.ts +3 -3
- package/lib/rolldown-config/input.d.ts +1 -1
- package/lib/rolldown-config/output.d.ts +15 -1
- package/lib/rolldown-config/plugins/circulars.d.ts +9 -9
- package/lib/rolldown-config/plugins/clean.cjs +3 -1
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +13 -4
- package/lib/rolldown-config/plugins/clean.js +4 -2
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.d.ts +7 -7
- package/lib/rolldown-config/plugins/index.d.ts +23 -2
- package/lib/rolldown-config/plugins/typescript.cjs +29 -41
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs +46 -39
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.d.ts +2 -4
- package/lib/rolldown-config/plugins/typescript.config.js +47 -41
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
- package/lib/rolldown-config/plugins/typescript.js +29 -43
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/types.d.ts +13 -13
- package/lib/utils/array.d.ts +1 -1
- package/lib/utils/identity.d.ts +1 -1
- package/lib/utils/index.d.ts +4 -4
- package/lib/utils/sleep.d.ts +1 -1
- package/lib/utils/types.d.ts +1 -4
- package/lib/vitest-exclude/index.d.ts +1 -1
- package/lib/vitest-exclude/types.d.ts +11 -8
- package/lib/vitest-exclude/vitest.cjs +0 -2
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +27 -15
- package/lib/vitest-exclude/vitest.js +0 -2
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
- package/lib/vitest-extended/acceptation.d.ts +3 -2
- package/lib/vitest-extended/bemedev/globals/types.d.ts +1 -4
- package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +10 -10
- package/lib/vitest-extended/createTests.d.ts +55 -34
- package/lib/vitest-extended/createTests.types.d.ts +6 -10
- package/lib/vitest-extended/done.d.ts +14 -8
- package/lib/vitest-extended/each/error.d.ts +1 -1
- package/lib/vitest-extended/each/error.types.d.ts +4 -10
- package/lib/vitest-extended/each/index.d.ts +2 -2
- package/lib/vitest-extended/each/pass.d.ts +26 -26
- package/lib/vitest-extended/each/pass.types.d.ts +6 -18
- package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
- package/lib/vitest-extended/identity.d.ts +2 -2
- package/lib/vitest-extended/index.cjs +2 -0
- package/lib/vitest-extended/index.d.ts +7 -6
- package/lib/vitest-extended/index.js +2 -1
- package/lib/vitest-extended/isDefined.d.ts +1 -1
- package/lib/vitest-extended/isFunction.d.ts +1 -1
- package/lib/vitest-extended/project.cjs +23 -0
- package/lib/vitest-extended/project.cjs.map +1 -0
- package/lib/vitest-extended/project.d.ts +2 -0
- package/lib/vitest-extended/project.js +22 -0
- package/lib/vitest-extended/project.js.map +1 -0
- package/lib/vitest-extended/toArray.d.ts +1 -1
- package/lib/vitest-extended/toStringFlat.d.ts +1 -1
- package/lib/vitest-extended/types.d.ts +38 -40
- package/package.json +3 -7
|
@@ -1,18 +1,30 @@
|
|
|
1
|
-
import type { Plugin } from
|
|
2
|
-
import type { Args } from
|
|
1
|
+
import type { Plugin } from 'vitest/config';
|
|
2
|
+
import type { Args, WithPattern } from './types';
|
|
3
3
|
/**
|
|
4
|
-
* Create includeTest and includeCoverage arrays from glob patterns
|
|
5
|
-
*
|
|
6
|
-
* @param args Globs to ignore for test and coverage files
|
|
7
|
-
* @returns An object with includeTest and includeCoverage string arrays
|
|
8
|
-
*/
|
|
9
|
-
export declare function create(args?: Args[1], root?: string)
|
|
4
|
+
* Create includeTest and includeCoverage arrays from glob patterns
|
|
5
|
+
*
|
|
6
|
+
* @param args Globs to ignore for test and coverage files
|
|
7
|
+
* @returns An object with includeTest and includeCoverage string arrays
|
|
8
|
+
*/
|
|
9
|
+
export declare function create(args?: Args[1], root?: string): Promise<{
|
|
10
|
+
files: string[];
|
|
11
|
+
coverage: string[];
|
|
12
|
+
}>;
|
|
13
|
+
export declare namespace create {
|
|
14
|
+
var withPattern: ({ patternTest, patternCov }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1], root?: string) => Promise<{
|
|
15
|
+
files: string[];
|
|
16
|
+
coverage: string[];
|
|
17
|
+
}>;
|
|
18
|
+
}
|
|
10
19
|
/**
|
|
11
|
-
* Plugin to add files with glob patterns to vitest
|
|
12
|
-
*
|
|
13
|
-
* @remarks You don't have to use test.exclude. The default search pattern is : './src/**\/*.ts'
|
|
14
|
-
* @param ignore Globs to exclude inside
|
|
15
|
-
* @returns A vitest config
|
|
16
|
-
* @see {@link exclude.withPattern}
|
|
17
|
-
*/
|
|
20
|
+
* Plugin to add files with glob patterns to vitest
|
|
21
|
+
*
|
|
22
|
+
* @remarks You don't have to use test.exclude. The default search pattern is : './src/**\/*.ts'
|
|
23
|
+
* @param ignore Globs to exclude inside
|
|
24
|
+
* @returns A vitest config
|
|
25
|
+
* @see {@link exclude.withPattern}
|
|
26
|
+
*/
|
|
18
27
|
export declare function exclude(args?: Args[1]): Plugin;
|
|
28
|
+
export declare namespace exclude {
|
|
29
|
+
var withPattern: WithPattern;
|
|
30
|
+
}
|
|
@@ -31,7 +31,6 @@ create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles,
|
|
|
31
31
|
function exclude(args = {}) {
|
|
32
32
|
return {
|
|
33
33
|
name,
|
|
34
|
-
enforce: "pre",
|
|
35
34
|
config: async (options) => {
|
|
36
35
|
const root = options?.root ?? process.cwd();
|
|
37
36
|
const testConfig = options?.test;
|
|
@@ -70,7 +69,6 @@ function exclude(args = {}) {
|
|
|
70
69
|
exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, ignoreTestFiles }) => {
|
|
71
70
|
return {
|
|
72
71
|
name,
|
|
73
|
-
enforce: "pre",
|
|
74
72
|
config: async (options) => {
|
|
75
73
|
const root = options?.root ?? process.cwd();
|
|
76
74
|
const testConfig = options?.test;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns An object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @remarks You don't have to use test.exclude. The default search pattern is : './src/**\\/*.ts'\n * @param ignore Globs to exclude inside\n * @returns A vitest config\n * @see {@link exclude.withPattern}\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n
|
|
1
|
+
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import type { Plugin } from 'vitest/config';\n\nimport { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\n\n/**\n * Create includeTest and includeCoverage arrays from glob patterns\n *\n * @param args Globs to ignore for test and coverage files\n * @returns An object with includeTest and includeCoverage string arrays\n */\nexport async function create(args: Args[1] = {}, root?: string) {\n const firsts = {\n patternTest: testPattern(root),\n patternCov: defaultCovPattern(root),\n };\n\n return create.withPattern(firsts, args, root);\n}\n\ncreate.withPattern = async (\n { patternTest, patternCov }: Partial<Args[0]> = {},\n { ignoreTestFiles, ignoreCoverageFiles }: Args[1] = {},\n root?: string,\n) => {\n const files = await buildInclude(\n patternTest ?? testPattern(root),\n ignoreTestFiles,\n root,\n );\n const coverage = await buildInclude(\n patternCov ?? defaultCovPattern(root),\n ignoreCoverageFiles,\n root,\n );\n return { files, coverage };\n};\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @remarks You don't have to use test.exclude. The default search pattern is : './src/**\\/*.ts'\n * @param ignore Globs to exclude inside\n * @returns A vitest config\n * @see {@link exclude.withPattern}\n */\nexport function exclude(args: Args[1] = {}) {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const patternCov = defaultCovPattern(root);\n const patternTest = testPattern(root);\n\n const { ignoreCoverageFiles, ignoreTestFiles } = args;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n } as Plugin;\n}\n\n/**\n * Plugin to add files with glob patterns to vitest\n *\n * @param pattern The pattern where searching files\n * @param ignore Globs to exclude inside\n * @returns A vitest config\n */\nexclude.withPattern = ((\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n) => {\n return {\n name,\n config: async options => {\n const root = options?.root ?? process.cwd();\n const testConfig = options?.test;\n const coverage = options?.test?.coverage;\n\n const all = await create.withPattern(\n { patternTest, patternCov },\n { ignoreCoverageFiles, ignoreTestFiles },\n root,\n );\n\n return {\n ...options,\n test: {\n ...testConfig,\n include: all.files,\n coverage: { ...coverage, include: all.coverage },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;AAgBA,eAAsB,OAAO,OAAgB,CAAC,GAAG,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,IAAI;EAC7B,YAAY,kBAAkB,IAAI;CACpC;CAEA,OAAO,OAAO,YAAY,QAAQ,MAAM,IAAI;AAC9C;AAEA,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,CAAC,GACjD,EAAE,iBAAiB,wBAAiC,CAAC,GACrD,SACG;CAWH,OAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALO,aACrB,cAAc,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;;AAUA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,IAAI;GACzC,MAAM,cAAc,YAAY,IAAI;GAEpC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF;;;;;;;;AASA,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;CACH,OAAO;EACL;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;GAAW,GAC1B;IAAE;IAAqB;GAAgB,GACvC,IACF;GAEA,OAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MAAE,GAAG;MAAU,SAAS,IAAI;KAAS;IACjD;GACF;EACF;CACF;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const hasSrc:
|
|
1
|
+
export declare const hasSrc: (root?: string) => boolean;
|
|
2
2
|
export declare const defaultCovPattern: (root?: string) => string;
|
|
3
|
-
export declare const buildInclude:
|
|
3
|
+
export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
|
|
4
4
|
export declare const testPattern: (root?: string) => string;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Fn } from './bemedev/globals/types';
|
|
2
|
+
export declare const useTestFunctionAcceptation: (f: Fn, _name?: string) => void;
|
|
2
3
|
/** For test only useTestFunctionAcceptation */
|
|
3
|
-
export declare const useTFA:
|
|
4
|
+
export declare const useTFA: (f: Fn, _name?: string) => void;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* _unknown variable - Auto-generated expression
|
|
3
|
-
*
|
|
4
|
-
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
5
|
-
* modified. Any manual changes will be overwritten during the next
|
|
6
|
-
* generation.
|
|
7
|
-
*
|
|
8
|
-
* @author chlbri (bri_lvi@icloud.com)
|
|
9
|
-
* @generated
|
|
10
|
-
* @readonly
|
|
11
|
-
*/
|
|
2
|
+
* _unknown variable - Auto-generated expression
|
|
3
|
+
*
|
|
4
|
+
* ⚠️ WARNING: This expression is auto-generated and should not be
|
|
5
|
+
* modified. Any manual changes will be overwritten during the next
|
|
6
|
+
* generation.
|
|
7
|
+
*
|
|
8
|
+
* @author chlbri (bri_lvi@icloud.com)
|
|
9
|
+
* @generated
|
|
10
|
+
* @readonly
|
|
11
|
+
*/
|
|
12
12
|
export declare const _unknown: <T>(value?: unknown) => T;
|
|
@@ -1,36 +1,57 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Fn } from './bemedev/globals/types';
|
|
2
|
+
import type { _CreateTests_F } from './createTests.types';
|
|
2
3
|
export type { _CreateTests_F };
|
|
3
4
|
/**
|
|
4
|
-
* Creates tests for function in a better way NB : We use strict-equality,
|
|
5
|
-
* {@link useEach|see}
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* // ./add.ts
|
|
9
|
-
* *export const add = (args: string[]) => args.reduce(
|
|
10
|
-
* (acc, value) => {
|
|
11
|
-
* acc+=value
|
|
12
|
-
* return acc;
|
|
13
|
-
* },
|
|
14
|
-
* 0)
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
* // .add.test.ts
|
|
18
|
-
* *import { createTests } from '@bemedev/vitest-extended';
|
|
19
|
-
* *import { add } from './add';
|
|
20
|
-
*
|
|
21
|
-
* *const useTests = createTests(add)
|
|
22
|
-
*
|
|
23
|
-
* *useTests(
|
|
24
|
-
* {
|
|
25
|
-
* invite: 'For : 1,2,3,4,5,6,7,8,9',
|
|
26
|
-
* parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
|
|
27
|
-
* }
|
|
28
|
-
* )
|
|
29
|
-
*
|
|
30
|
-
* @param library The test library
|
|
31
|
-
* @param f The function to test
|
|
32
|
-
* @param *
|
|
33
|
-
* @returns A test.each like function to tests many cases NB: If the first
|
|
34
|
-
* argument is an array, wrap the value in another array,
|
|
35
|
-
*/
|
|
36
|
-
export declare const createTests:
|
|
5
|
+
* Creates tests for function in a better way NB : We use strict-equality,
|
|
6
|
+
* {@link useEach|see}
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* // ./add.ts
|
|
10
|
+
* *export const add = (args: string[]) => args.reduce(
|
|
11
|
+
* (acc, value) => {
|
|
12
|
+
* acc+=value
|
|
13
|
+
* return acc;
|
|
14
|
+
* },
|
|
15
|
+
* 0)
|
|
16
|
+
*
|
|
17
|
+
*
|
|
18
|
+
* // .add.test.ts
|
|
19
|
+
* *import { createTests } from '@bemedev/vitest-extended';
|
|
20
|
+
* *import { add } from './add';
|
|
21
|
+
*
|
|
22
|
+
* *const useTests = createTests(add)
|
|
23
|
+
*
|
|
24
|
+
* *useTests(
|
|
25
|
+
* {
|
|
26
|
+
* invite: 'For : 1,2,3,4,5,6,7,8,9',
|
|
27
|
+
* parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!
|
|
28
|
+
* }
|
|
29
|
+
* )
|
|
30
|
+
*
|
|
31
|
+
* @param library The test library
|
|
32
|
+
* @param f The function to test
|
|
33
|
+
* @param *
|
|
34
|
+
* @returns A test.each like function to tests many cases NB: If the first
|
|
35
|
+
* argument is an array, wrap the value in another array,
|
|
36
|
+
*/
|
|
37
|
+
export declare const createTests: {
|
|
38
|
+
<F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, args?: {
|
|
39
|
+
transform?: Fn<[Awaited<F1>], F2>;
|
|
40
|
+
toError?: Fn<F0, string | undefined>;
|
|
41
|
+
}): {
|
|
42
|
+
acceptation: () => void;
|
|
43
|
+
success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
|
|
44
|
+
fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
|
|
45
|
+
};
|
|
46
|
+
withImplementation<F0 extends any[], F1, F2 = F1>(f: Fn<NoInfer<F0>, NoInfer<F1>>, { instanciation, name, transform, toError, }: {
|
|
47
|
+
instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;
|
|
48
|
+
name: string;
|
|
49
|
+
transform?: Fn<[Awaited<F1>], F2>;
|
|
50
|
+
toError?: Fn<F0, string | undefined>;
|
|
51
|
+
}): {
|
|
52
|
+
acceptation: () => void;
|
|
53
|
+
success: (...cases: import("./types").TestArgs<Fn<F0, F2>>) => () => void;
|
|
54
|
+
fails: (...cases: import("./types").TestErrors<Fn<F0, F2>>) => () => void;
|
|
55
|
+
};
|
|
56
|
+
withoutImplementation: /*elided*/ any;
|
|
57
|
+
};
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import type { Fn } from
|
|
2
|
-
import type { TestArgs, TestErrors } from
|
|
1
|
+
import type { Fn } from './bemedev/globals/types';
|
|
2
|
+
import type { TestArgs, TestErrors } from './types';
|
|
3
3
|
type ReturnR<F extends Fn> = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
acceptation: () => void;
|
|
5
|
+
success: (...cases: TestArgs<F>) => () => void;
|
|
6
|
+
fails: (...cases: TestErrors<F>) => () => void;
|
|
7
7
|
};
|
|
8
|
-
export type _CreateTests_F = <
|
|
9
|
-
F0 extends any[],
|
|
10
|
-
F1,
|
|
11
|
-
F2 = F1
|
|
12
|
-
>(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
|
|
8
|
+
export type _CreateTests_F = <F0 extends any[], F1, F2 = F1>(func: Fn<F0, F1>, transform?: Fn<[Awaited<F1>], F2>, toError?: Fn<F0, string | undefined>, name?: string) => ReturnR<Fn<F0, F2>>;
|
|
13
9
|
export {};
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
+
import { type TestOptions } from 'vitest';
|
|
2
|
+
import type { TestDoneFunction } from './types';
|
|
1
3
|
/**
|
|
2
|
-
* Build a test with a done function with a timeout
|
|
3
|
-
*
|
|
4
|
-
* @param invite The description of the test
|
|
5
|
-
* @param fn Where you can test, Don't async this function
|
|
6
|
-
* @param options Options for the test like TestAPI from vitest
|
|
7
|
-
* @returns A vitest test
|
|
8
|
-
*/
|
|
9
|
-
export declare const doneTest:
|
|
4
|
+
* Build a test with a done function with a timeout
|
|
5
|
+
*
|
|
6
|
+
* @param invite The description of the test
|
|
7
|
+
* @param fn Where you can test, Don't async this function
|
|
8
|
+
* @param options Options for the test like TestAPI from vitest
|
|
9
|
+
* @returns A vitest test
|
|
10
|
+
*/
|
|
11
|
+
export declare const doneTest: {
|
|
12
|
+
(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
|
|
13
|
+
fails(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
|
|
14
|
+
concurrent(invite: string, fn: TestDoneFunction, options?: number | TestOptions): void;
|
|
15
|
+
};
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { Fn } from
|
|
2
|
-
import type { Identity, NextFn, TestErrors } from
|
|
1
|
+
import type { Fn } from '../bemedev/globals/types';
|
|
2
|
+
import type { Identity, NextFn, TestErrors } from '../types';
|
|
3
3
|
export type ToError_F<F extends Fn> = (...params: Parameters<F>) => string | undefined;
|
|
4
|
-
export type _UseErrorEach_F = <
|
|
5
|
-
|
|
6
|
-
T extends NextFn<F> = Identity<F>
|
|
7
|
-
>(f: F, transform?: T, toError?: ToError_F<F>, ...cases: TestErrors<F>) => void;
|
|
8
|
-
export type UseErrorEach_F = <
|
|
9
|
-
F extends Fn,
|
|
10
|
-
T extends NextFn<F> = Identity<F>
|
|
11
|
-
>(f: F, transform?: T, toError?: ToError_F<F>) => Fn<TestErrors<F>, void>;
|
|
4
|
+
export type _UseErrorEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, toError?: ToError_F<F>, ...cases: TestErrors<F>) => void;
|
|
5
|
+
export type UseErrorEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, toError?: ToError_F<F>) => Fn<TestErrors<F>, void>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './error';
|
|
2
|
+
export * from './pass';
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import type { UseAsyncEach_F, UseEach_F } from
|
|
1
|
+
import type { UseAsyncEach_F, UseEach_F } from './pass.types';
|
|
2
2
|
/**
|
|
3
|
-
* A better version of **test.each**
|
|
4
|
-
*
|
|
5
|
-
* Type parameters
|
|
6
|
-
*
|
|
7
|
-
* @type A Parameters of the function, extends Array type
|
|
8
|
-
* @type R ReturnType of the function
|
|
9
|
-
* @param func The function to test
|
|
10
|
-
* @param cases The cases to test, The invite is the first arguments. It's
|
|
11
|
-
* an array of Array.
|
|
12
|
-
*
|
|
13
|
-
* - #1 The first arg is the invite of the test
|
|
14
|
-
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
15
|
-
* an array (param array).
|
|
16
|
-
* - #3 The third arg is the expected result
|
|
17
|
-
*
|
|
18
|
-
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
19
|
-
* with be : **_[string]**_
|
|
20
|
-
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
21
|
-
*
|
|
22
|
-
* @else It tests every cases provided
|
|
23
|
-
*/
|
|
3
|
+
* A better version of **test.each**
|
|
4
|
+
*
|
|
5
|
+
* Type parameters
|
|
6
|
+
*
|
|
7
|
+
* @type A Parameters of the function, extends Array type
|
|
8
|
+
* @type R ReturnType of the function
|
|
9
|
+
* @param func The function to test
|
|
10
|
+
* @param cases The cases to test, The invite is the first arguments. It's
|
|
11
|
+
* an array of Array.
|
|
12
|
+
*
|
|
13
|
+
* - #1 The first arg is the invite of the test
|
|
14
|
+
* - #2 The second arg is the parameters to to pass to the function. It's
|
|
15
|
+
* an array (param array).
|
|
16
|
+
* - #3 The third arg is the expected result
|
|
17
|
+
*
|
|
18
|
+
* Example: For a function like **_(arg1: string)=>any**_, the second arg
|
|
19
|
+
* with be : **_[string]**_
|
|
20
|
+
* @if R are not provided, the return is a function to test with TestArgs arguments
|
|
21
|
+
*
|
|
22
|
+
* @else It tests every cases provided
|
|
23
|
+
*/
|
|
24
24
|
export declare const useEach: UseEach_F;
|
|
25
25
|
/**
|
|
26
|
-
* Same as _**useEach**_
|
|
27
|
-
*
|
|
28
|
-
* But for async functions
|
|
29
|
-
*/
|
|
26
|
+
* Same as _**useEach**_
|
|
27
|
+
*
|
|
28
|
+
* But for async functions
|
|
29
|
+
*/
|
|
30
30
|
export declare const useEachAsync: UseAsyncEach_F;
|
|
@@ -1,18 +1,6 @@
|
|
|
1
|
-
import type { Fn } from
|
|
2
|
-
import type { ChainedFn, Identity, NextFn, TestArgs } from
|
|
3
|
-
export type _UseEach_F = <
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
>(f: F, transform?: T
|
|
7
|
-
export type UseEach_F = <
|
|
8
|
-
F extends Fn,
|
|
9
|
-
T extends NextFn<F> = Identity<F>
|
|
10
|
-
>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
11
|
-
export type _UseAsyncEach_F = <
|
|
12
|
-
F extends Fn<any, Promise<any>>,
|
|
13
|
-
T extends NextFn<F> = Identity<F>
|
|
14
|
-
>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
15
|
-
export type UseAsyncEach_F = <
|
|
16
|
-
F extends Fn<any, Promise<any>>,
|
|
17
|
-
T extends NextFn<F> = Identity<F>
|
|
18
|
-
>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
1
|
+
import type { Fn } from '../bemedev/globals/types';
|
|
2
|
+
import type { ChainedFn, Identity, NextFn, TestArgs } from '../types';
|
|
3
|
+
export type _UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
4
|
+
export type UseEach_F = <F extends Fn, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
5
|
+
export type _UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
6
|
+
export type UseAsyncEach_F = <F extends Fn<any, Promise<any>>, T extends NextFn<F> = Identity<F>>(f: F, transform?: T) => (...cases: TestArgs<ChainedFn<F, T>>) => void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { VitestUtils } from
|
|
1
|
+
import type { VitestUtils } from 'vitest';
|
|
2
2
|
export type FakeWaiter1_F = (vi: VitestUtils) => (ms?: number, times?: number) => Promise<void>;
|
|
3
3
|
export type FakeWaiter2_F = (vi: VitestUtils, ms?: number) => (index: number, times?: number) => [string, () => Promise<void>];
|
|
4
4
|
export type FakeWaiter3_F = (vi: VitestUtils) => (index: number, ms?: number, times?: number) => [string, () => Promise<void>];
|
|
5
5
|
export type FakeWaiter = FakeWaiter1_F & {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
withDefaultDelay: FakeWaiter2_F;
|
|
7
|
+
all: FakeWaiter3_F;
|
|
8
8
|
};
|
|
9
9
|
export declare const createFakeWaiter: FakeWaiter;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const identity:
|
|
2
|
-
export declare const defaultEquality:
|
|
1
|
+
export declare const identity: <T>(value: T) => T;
|
|
2
|
+
export declare const defaultEquality: (value: any, expected: any) => void;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_vitest_extended_project = require("./project.cjs");
|
|
2
3
|
const require_vitest_extended_acceptation = require("./acceptation.cjs");
|
|
3
4
|
const require_vitest_extended_each_error = require("./each/error.cjs");
|
|
4
5
|
const require_vitest_extended_each_pass = require("./each/pass.cjs");
|
|
@@ -8,6 +9,7 @@ require("./each/index.cjs");
|
|
|
8
9
|
const require_vitest_extended_fakeWaiter = require("./fakeWaiter.cjs");
|
|
9
10
|
exports.createFakeWaiter = require_vitest_extended_fakeWaiter.createFakeWaiter;
|
|
10
11
|
exports.createTests = require_vitest_extended_createTests.createTests;
|
|
12
|
+
exports.defineProject = require_vitest_extended_project.defineProject;
|
|
11
13
|
exports.doneTest = require_vitest_extended_done.doneTest;
|
|
12
14
|
exports.useEach = require_vitest_extended_each_pass.useEach;
|
|
13
15
|
exports.useEachAsync = require_vitest_extended_each_pass.useEachAsync;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
1
|
+
export * from './acceptation';
|
|
2
|
+
export * from './createTests';
|
|
3
|
+
export * from './done';
|
|
4
|
+
export * from './each';
|
|
5
|
+
export * from './fakeWaiter';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './project';
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { defineProject } from "./project.js";
|
|
1
2
|
import { useTFA, useTestFunctionAcceptation } from "./acceptation.js";
|
|
2
3
|
import { useErrorAsyncEach, useErrorAsyncEachCases } from "./each/error.js";
|
|
3
4
|
import { useEach, useEachAsync } from "./each/pass.js";
|
|
@@ -5,4 +6,4 @@ import { createTests } from "./createTests.js";
|
|
|
5
6
|
import { doneTest } from "./done.js";
|
|
6
7
|
import "./each/index.js";
|
|
7
8
|
import { createFakeWaiter } from "./fakeWaiter.js";
|
|
8
|
-
export { createFakeWaiter, createTests, doneTest, useEach, useEachAsync, useErrorAsyncEach, useErrorAsyncEachCases, useTFA, useTestFunctionAcceptation };
|
|
9
|
+
export { createFakeWaiter, createTests, defineProject, doneTest, useEach, useEachAsync, useErrorAsyncEach, useErrorAsyncEachCases, useTFA, useTestFunctionAcceptation };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function isFunction(arg: any);
|
|
1
|
+
export declare function isFunction(arg: any): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let vitest_config = require("vitest/config");
|
|
3
|
+
//#region src/vitest-extended/project.ts
|
|
4
|
+
const defineProject = (conf) => {
|
|
5
|
+
const _env = conf.test?.env ?? {};
|
|
6
|
+
return (0, vitest_config.defineConfig)({
|
|
7
|
+
resolve: { tsconfigPaths: true },
|
|
8
|
+
...conf,
|
|
9
|
+
test: {
|
|
10
|
+
globals: true,
|
|
11
|
+
logHeapUsage: false,
|
|
12
|
+
env: {
|
|
13
|
+
NODE_ENV: "test",
|
|
14
|
+
..._env
|
|
15
|
+
},
|
|
16
|
+
...conf.test
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
exports.defineProject = defineProject;
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=project.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.cjs","names":[],"sources":["../../src/vitest-extended/project.ts"],"sourcesContent":["import { defineConfig, type UserWorkspaceConfig } from 'vitest/config';\n\nexport const defineProject = (conf: UserWorkspaceConfig) => {\n const _env = conf.test?.env ?? {};\n\n return defineConfig({\n resolve: { tsconfigPaths: true },\n ...conf,\n test: {\n globals: true,\n logHeapUsage: false,\n env: { NODE_ENV: 'test', ..._env },\n ...conf.test,\n },\n });\n};\n"],"mappings":";;;AAEA,MAAa,iBAAiB,SAA8B;CAC1D,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC;CAEhC,QAAA,GAAA,cAAA,aAAA,CAAoB;EAClB,SAAS,EAAE,eAAe,KAAK;EAC/B,GAAG;EACH,MAAM;GACJ,SAAS;GACT,cAAc;GACd,KAAK;IAAE,UAAU;IAAQ,GAAG;GAAK;GACjC,GAAG,KAAK;EACV;CACF,CAAC;AACH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineConfig } from "vitest/config";
|
|
2
|
+
//#region src/vitest-extended/project.ts
|
|
3
|
+
const defineProject = (conf) => {
|
|
4
|
+
const _env = conf.test?.env ?? {};
|
|
5
|
+
return defineConfig({
|
|
6
|
+
resolve: { tsconfigPaths: true },
|
|
7
|
+
...conf,
|
|
8
|
+
test: {
|
|
9
|
+
globals: true,
|
|
10
|
+
logHeapUsage: false,
|
|
11
|
+
env: {
|
|
12
|
+
NODE_ENV: "test",
|
|
13
|
+
..._env
|
|
14
|
+
},
|
|
15
|
+
...conf.test
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
//#endregion
|
|
20
|
+
export { defineProject };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","names":[],"sources":["../../src/vitest-extended/project.ts"],"sourcesContent":["import { defineConfig, type UserWorkspaceConfig } from 'vitest/config';\n\nexport const defineProject = (conf: UserWorkspaceConfig) => {\n const _env = conf.test?.env ?? {};\n\n return defineConfig({\n resolve: { tsconfigPaths: true },\n ...conf,\n test: {\n globals: true,\n logHeapUsage: false,\n env: { NODE_ENV: 'test', ..._env },\n ...conf.test,\n },\n });\n};\n"],"mappings":";;AAEA,MAAa,iBAAiB,SAA8B;CAC1D,MAAM,OAAO,KAAK,MAAM,OAAO,CAAC;CAEhC,OAAO,aAAa;EAClB,SAAS,EAAE,eAAe,KAAK;EAC/B,GAAG;EACH,MAAM;GACJ,SAAS;GACT,cAAc;GACd,KAAK;IAAE,UAAU;IAAQ,GAAG;GAAK;GACjC,GAAG,KAAK;EACV;CACF,CAAC;AACH"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type Fn } from
|
|
1
|
+
import { type Fn } from './bemedev/globals/types';
|
|
2
2
|
export declare const toStringFlat: Fn<[value: number, len: number], string>;
|
|
@@ -1,62 +1,60 @@
|
|
|
1
|
-
import type { Fn, RuA } from
|
|
1
|
+
import type { Fn, RuA } from './bemedev/globals/types';
|
|
2
2
|
export type { Fn, RuA };
|
|
3
3
|
type ReR<F extends Fn> = Awaited<ReturnType<F>>;
|
|
4
4
|
type TestFn<F extends Fn> = Fn<[ReR<F>, ReR<F>], void>;
|
|
5
|
-
type LengthOf<T> = T extends readonly any[] ? T[
|
|
6
|
-
export type SimpleParams<
|
|
7
|
-
|
|
8
|
-
P extends RuA = Parameters<F>
|
|
9
|
-
> = LengthOf<P> extends 0 ? {
|
|
10
|
-
parameters?: never;
|
|
5
|
+
type LengthOf<T> = T extends readonly any[] ? T['length'] : never;
|
|
6
|
+
export type SimpleParams<F extends Fn, P extends RuA = Parameters<F>> = LengthOf<P> extends 0 ? {
|
|
7
|
+
parameters?: never;
|
|
11
8
|
} : 1 extends LengthOf<P> ? undefined extends P[0] ? {
|
|
12
|
-
|
|
9
|
+
parameters?: P | P[0];
|
|
13
10
|
} : 0 extends LengthOf<P> ? {
|
|
14
|
-
|
|
11
|
+
parameters?: P | P[0];
|
|
15
12
|
} : {
|
|
16
|
-
|
|
13
|
+
parameters: P | P[0];
|
|
17
14
|
} : {
|
|
18
|
-
|
|
15
|
+
parameters: P;
|
|
19
16
|
};
|
|
20
17
|
export type TestArgs<F extends Fn> = ({
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
invite: string;
|
|
19
|
+
expected: ReR<F>;
|
|
20
|
+
/** Optional test function for specific cases */
|
|
21
|
+
test?: TestFn<F>;
|
|
25
22
|
} & SimpleParams<F>)[];
|
|
26
|
-
export type TestArgs2<F extends Fn> = [
|
|
23
|
+
export type TestArgs2<F extends Fn> = [
|
|
24
|
+
invite: string,
|
|
25
|
+
parameters: Parameters<F>,
|
|
26
|
+
expected: ReR<F>,
|
|
27
|
+
/** Optional test function for specific cases */
|
|
28
|
+
test?: TestFn<F>
|
|
29
|
+
][];
|
|
27
30
|
export type TestErrors<F extends Fn> = ({
|
|
28
|
-
|
|
29
|
-
|
|
31
|
+
invite: string;
|
|
32
|
+
error?: string;
|
|
30
33
|
} & SimpleParams<F>)[];
|
|
31
|
-
export type TestErrors2<F extends Fn> = [
|
|
34
|
+
export type TestErrors2<F extends Fn> = [
|
|
35
|
+
invite: string,
|
|
36
|
+
parameters: Parameters<F>,
|
|
37
|
+
error?: string
|
|
38
|
+
][];
|
|
32
39
|
export interface ToArray_F {
|
|
33
|
-
|
|
34
|
-
|
|
40
|
+
<T>(obj: any): T[];
|
|
41
|
+
generic: <T>(obj: T) => T[];
|
|
35
42
|
}
|
|
36
43
|
export interface ToArrayVitest_F {
|
|
37
|
-
|
|
38
|
-
|
|
44
|
+
<F extends Fn>(params: TestArgs<F>): TestArgs2<F>;
|
|
45
|
+
error: <F extends Fn>(params: TestErrors<F>) => TestErrors2<F>;
|
|
39
46
|
}
|
|
40
|
-
export type TestReturn<
|
|
41
|
-
F extends Fn,
|
|
42
|
-
A extends TestArgs<F>
|
|
43
|
-
> = LengthOf<A> extends 0 ? Fn<TestArgs<F>, void> : void;
|
|
47
|
+
export type TestReturn<F extends Fn, A extends TestArgs<F>> = LengthOf<A> extends 0 ? Fn<TestArgs<F>, void> : void;
|
|
44
48
|
export type TestDoneFunction = Fn<[context: () => boolean], void>;
|
|
45
49
|
export type ToCreateTestsWithImplementation_F = <F extends Fn>(f: F, implementation: {
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
instanciation: () => Promise<F> | F;
|
|
51
|
+
name: string;
|
|
48
52
|
}) => (...cases: TestArgs<F>) => void;
|
|
49
53
|
export type FakeWaiter_F = (params: {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
ms?: number;
|
|
55
|
+
times?: number;
|
|
56
|
+
fake: boolean;
|
|
53
57
|
}) => Promise<void>;
|
|
54
|
-
export type NextFn<
|
|
55
|
-
F extends Fn,
|
|
56
|
-
R = any
|
|
57
|
-
> = Fn<[ReturnType<F>], R>;
|
|
58
|
+
export type NextFn<F extends Fn, R = any> = Fn<[ReturnType<F>], R>;
|
|
58
59
|
export type Identity<F extends Fn> = Fn<[ReturnType<F>], ReturnType<F>>;
|
|
59
|
-
export type ChainedFn<
|
|
60
|
-
F extends Fn,
|
|
61
|
-
T extends NextFn<F>
|
|
62
|
-
> = Fn<Parameters<F>, ReR<T>>;
|
|
60
|
+
export type ChainedFn<F extends Fn, T extends NextFn<F>> = Fn<Parameters<F>, ReR<T>>;
|