@bemedev/dev-utils 1.0.1 → 1.1.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.
Files changed (125) hide show
  1. package/README.md +59 -11
  2. package/lib/build-tests/addTarball.d.ts +1 -1
  3. package/lib/build-tests/buildPackageJson.d.ts +3 -3
  4. package/lib/build-tests/cleanup.d.ts +1 -1
  5. package/lib/build-tests/cli/cli.d.ts +51 -1
  6. package/lib/build-tests/cli/index.d.ts +1 -0
  7. package/lib/build-tests/cli/post.d.ts +5 -1
  8. package/lib/build-tests/cli/pre.d.ts +5 -1
  9. package/lib/build-tests/cli/test.d.ts +15 -1
  10. package/lib/build-tests/constants.d.ts +1 -1
  11. package/lib/build-tests/getRelativePath.d.ts +1 -1
  12. package/lib/build-tests/getTypescriptOutdir.d.ts +1 -1
  13. package/lib/build-tests/import.d.ts +2 -2
  14. package/lib/build-tests/imports/create.d.ts +3 -3
  15. package/lib/build-tests/imports/helper.cjs.map +1 -1
  16. package/lib/build-tests/imports/helper.d.ts +7 -3
  17. package/lib/build-tests/imports/helper.js.map +1 -1
  18. package/lib/build-tests/imports/index.d.ts +1 -1
  19. package/lib/build-tests/index.d.ts +5 -5
  20. package/lib/build-tests/pack.d.ts +1 -1
  21. package/lib/rolldown-config/config.cjs +23 -2
  22. package/lib/rolldown-config/config.cjs.map +1 -1
  23. package/lib/rolldown-config/config.d.ts +1 -1
  24. package/lib/rolldown-config/config.js +23 -2
  25. package/lib/rolldown-config/config.js.map +1 -1
  26. package/lib/rolldown-config/constants.d.ts +5 -5
  27. package/lib/rolldown-config/helpers.d.ts +2 -2
  28. package/lib/rolldown-config/index.d.ts +3 -3
  29. package/lib/rolldown-config/input.d.ts +1 -1
  30. package/lib/rolldown-config/output.cjs +4 -2
  31. package/lib/rolldown-config/output.cjs.map +1 -1
  32. package/lib/rolldown-config/output.d.ts +15 -1
  33. package/lib/rolldown-config/output.js +4 -2
  34. package/lib/rolldown-config/output.js.map +1 -1
  35. package/lib/rolldown-config/plugins/circulars.d.ts +9 -9
  36. package/lib/rolldown-config/plugins/clean.cjs +4 -2
  37. package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
  38. package/lib/rolldown-config/plugins/clean.d.ts +13 -4
  39. package/lib/rolldown-config/plugins/clean.js +4 -2
  40. package/lib/rolldown-config/plugins/clean.js.map +1 -1
  41. package/lib/rolldown-config/plugins/externals.d.ts +7 -7
  42. package/lib/rolldown-config/plugins/index.cjs +8 -8
  43. package/lib/rolldown-config/plugins/index.cjs.map +1 -1
  44. package/lib/rolldown-config/plugins/index.d.ts +31 -2
  45. package/lib/rolldown-config/plugins/index.js +6 -7
  46. package/lib/rolldown-config/plugins/index.js.map +1 -1
  47. package/lib/rolldown-config/plugins/typescript.cjs +29 -41
  48. package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
  49. package/lib/rolldown-config/plugins/typescript.config.cjs +51 -39
  50. package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
  51. package/lib/rolldown-config/plugins/typescript.config.d.ts +3 -4
  52. package/lib/rolldown-config/plugins/typescript.config.js +51 -41
  53. package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
  54. package/lib/rolldown-config/plugins/typescript.d.ts +6 -6
  55. package/lib/rolldown-config/plugins/typescript.fast.cjs +80 -0
  56. package/lib/rolldown-config/plugins/typescript.fast.cjs.map +1 -0
  57. package/lib/rolldown-config/plugins/typescript.fast.d.ts +9 -0
  58. package/lib/rolldown-config/plugins/typescript.fast.js +77 -0
  59. package/lib/rolldown-config/plugins/typescript.fast.js.map +1 -0
  60. package/lib/rolldown-config/plugins/typescript.js +29 -43
  61. package/lib/rolldown-config/plugins/typescript.js.map +1 -1
  62. package/lib/rolldown-config/types.d.ts +14 -13
  63. package/lib/utils/array.d.ts +1 -1
  64. package/lib/utils/bemedev/globals/types.d.ts +4 -0
  65. package/lib/{vitest-extended → utils}/bemedev/globals/utils/_unknown.cjs +1 -1
  66. package/lib/utils/bemedev/globals/utils/_unknown.cjs.map +1 -0
  67. package/lib/utils/bemedev/globals/utils/_unknown.d.ts +12 -0
  68. package/lib/{vitest-extended → utils}/bemedev/globals/utils/_unknown.js +1 -1
  69. package/lib/utils/bemedev/globals/utils/_unknown.js.map +1 -0
  70. package/lib/utils/bemedev/globals/utils/expandFn.cjs +11 -0
  71. package/lib/utils/bemedev/globals/utils/expandFn.cjs.map +1 -0
  72. package/lib/utils/bemedev/globals/utils/expandFn.d.ts +2 -0
  73. package/lib/utils/bemedev/globals/utils/expandFn.js +10 -0
  74. package/lib/utils/bemedev/globals/utils/expandFn.js.map +1 -0
  75. package/lib/utils/identity.d.ts +1 -1
  76. package/lib/utils/index.cjs +2 -0
  77. package/lib/utils/index.d.ts +5 -4
  78. package/lib/utils/index.js +2 -1
  79. package/lib/utils/sleep.d.ts +1 -1
  80. package/lib/utils/types.d.ts +1 -4
  81. package/lib/vitest-exclude/index.d.ts +1 -1
  82. package/lib/vitest-exclude/types.d.ts +11 -8
  83. package/lib/vitest-exclude/vitest.cjs +0 -2
  84. package/lib/vitest-exclude/vitest.cjs.map +1 -1
  85. package/lib/vitest-exclude/vitest.d.ts +27 -15
  86. package/lib/vitest-exclude/vitest.js +0 -2
  87. package/lib/vitest-exclude/vitest.js.map +1 -1
  88. package/lib/vitest-exclude/vitest.utils.d.ts +2 -2
  89. package/lib/vitest-extended/acceptation.cjs.map +1 -1
  90. package/lib/vitest-extended/acceptation.d.ts +3 -2
  91. package/lib/vitest-extended/acceptation.js.map +1 -1
  92. package/lib/vitest-extended/createTests.cjs.map +1 -1
  93. package/lib/vitest-extended/createTests.d.ts +55 -34
  94. package/lib/vitest-extended/createTests.js.map +1 -1
  95. package/lib/vitest-extended/createTests.types.d.ts +6 -10
  96. package/lib/vitest-extended/done.d.ts +14 -8
  97. package/lib/vitest-extended/each/error.d.ts +1 -1
  98. package/lib/vitest-extended/each/error.types.d.ts +4 -10
  99. package/lib/vitest-extended/each/index.d.ts +2 -2
  100. package/lib/vitest-extended/each/pass.d.ts +26 -26
  101. package/lib/vitest-extended/each/pass.types.d.ts +6 -18
  102. package/lib/vitest-extended/fakeWaiter.d.ts +3 -3
  103. package/lib/vitest-extended/identity.d.ts +2 -2
  104. package/lib/vitest-extended/index.cjs +2 -0
  105. package/lib/vitest-extended/index.d.ts +7 -6
  106. package/lib/vitest-extended/index.js +2 -1
  107. package/lib/vitest-extended/isDefined.cjs.map +1 -1
  108. package/lib/vitest-extended/isDefined.d.ts +1 -1
  109. package/lib/vitest-extended/isDefined.js.map +1 -1
  110. package/lib/vitest-extended/isFunction.d.ts +1 -1
  111. package/lib/vitest-extended/project.cjs +23 -0
  112. package/lib/vitest-extended/project.cjs.map +1 -0
  113. package/lib/vitest-extended/project.d.ts +2 -0
  114. package/lib/vitest-extended/project.js +22 -0
  115. package/lib/vitest-extended/project.js.map +1 -0
  116. package/lib/vitest-extended/toArray.d.ts +1 -1
  117. package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
  118. package/lib/vitest-extended/toStringFlat.d.ts +1 -1
  119. package/lib/vitest-extended/toStringFlat.js.map +1 -1
  120. package/lib/vitest-extended/types.d.ts +38 -40
  121. package/package.json +4 -8
  122. package/lib/vitest-extended/bemedev/globals/types.d.ts +0 -6
  123. package/lib/vitest-extended/bemedev/globals/utils/_unknown.cjs.map +0 -1
  124. package/lib/vitest-extended/bemedev/globals/utils/_unknown.d.ts +0 -12
  125. package/lib/vitest-extended/bemedev/globals/utils/_unknown.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"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 enforce: 'pre',\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 enforce: 'pre',\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,aAAaA,oCAAAA,YAAY,IAAI;EAC7B,YAAYC,oCAAAA,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,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;;AAUA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,IAAI;GACzC,MAAM,cAAcD,oCAAAA,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,MAAA,iCAAA;EACA,SAAS;EACT,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
+ {"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"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,aAAaA,oCAAAA,YAAY,IAAI;EAC7B,YAAYC,oCAAAA,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,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,IAAI,GAC/B,iBACA,IACF;EAMgB,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,IAAI,GACpC,qBACA,IACF;CACyB;AAC3B;;;;;;;;;AAUA,SAAgB,QAAQ,OAAgB,CAAC,GAAG;CAC1C,OAAO;EACL,MAAA,iCAAA;EACA,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,IAAI;GAC1C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,IAAI;GACzC,MAAM,cAAcD,oCAAAA,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,MAAA,iCAAA;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,18 +1,30 @@
1
- import type { Plugin } from "vitest/config";
2
- import type { Args } from "./types";
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 enforce: 'pre',\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 enforce: 'pre',\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,SAAS;EACT,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,SAAS;EACT,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
+ {"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: unknown;
1
+ export declare const hasSrc: (root?: string) => boolean;
2
2
  export declare const defaultCovPattern: (root?: string) => string;
3
- export declare const buildInclude: unknown;
3
+ export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
4
4
  export declare const testPattern: (root?: string) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from './bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,oBAAoB;EACtC,CAAA,GAAA,OAAA,OAAA,CAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,uBAAuB;EAEzC,CAAA,GAAA,OAAA,OAAA,CADcA,mCAAAA,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
1
+ {"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,oBAAoB;EACtC,CAAA,GAAA,OAAA,OAAA,CAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,CAAA,GAAA,OAAA,KAAA,CAAK,UAAU,KAAK,uBAAuB;EAEzC,CAAA,GAAA,OAAA,OAAA,CADcA,mCAAAA,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
@@ -1,3 +1,4 @@
1
- export declare const useTestFunctionAcceptation: unknown;
1
+ import type { Fn } from '../utils/bemedev/globals/types';
2
+ export declare const useTestFunctionAcceptation: (f: Fn, _name?: string) => void;
2
3
  /** For test only useTestFunctionAcceptation */
3
- export declare const useTFA: unknown;
4
+ export declare const useTFA: (f: Fn, _name?: string) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from './bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,KAAK,UAAU,KAAK,oBAAoB;EACtC,OAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,KAAK,UAAU,KAAK,uBAAuB;EAEzC,OADc,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
1
+ {"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import { expect, test } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { isFunction } from './isFunction';\n\nexport const useTestFunctionAcceptation = (f: Fn, _name?: string) => {\n const name = _name ?? f.name;\n\n test(`#01 => ${name} is defined`, () => {\n expect(f).toBeDefined();\n });\n test(`#02 => ${name} is a function`, () => {\n const check = isFunction(f);\n expect(check).toBe(true);\n });\n};\n\n/** For test only useTestFunctionAcceptation */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAKA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;CAExB,KAAK,UAAU,KAAK,oBAAoB;EACtC,OAAO,CAAC,CAAC,CAAC,YAAY;CACxB,CAAC;CACD,KAAK,UAAU,KAAK,uBAAuB;EAEzC,OADc,WAAW,CACd,CAAC,CAAC,CAAC,KAAK,IAAI;CACzB,CAAC;AACH;;AAGA,MAAa,SAAS"}
@@ -1 +1 @@
1
- {"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiBC,mCAAAA,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViBC,kCAAAA,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,CAAA,GAAA,OAAA,UAAA,CAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
1
+ {"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiBC,mCAAAA,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViBC,kCAAAA,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,CAAA,GAAA,OAAA,UAAA,CAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
@@ -1,36 +1,57 @@
1
- import type { _CreateTests_F } from "./createTests.types";
1
+ import type { Fn } from '../utils/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: unknown;
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 +1 @@
1
- {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport { useTFA } from './acceptation';\nimport type { Fn } from './bemedev/globals/types';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmB,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiB,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViB,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,UAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
1
+ {"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\n\nimport type { Fn } from '../utils/bemedev/globals/types';\nimport { useTFA } from './acceptation';\nimport type { _CreateTests_F } from './createTests.types';\nimport { useErrorAsyncEach } from './each/error';\nimport {\n useEachAsync,\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n type useEach,\n} from './each/pass';\nimport { toStringFlat } from './toStringFlat';\n\nexport type { _CreateTests_F };\n\nconst _create: _CreateTests_F = (func, transform, toError, name) => {\n return {\n acceptation: () => useTFA(func, name),\n\n fails: (...cases) => {\n const length = cases.length;\n\n return () => {\n const useTests = useErrorAsyncEach(\n func,\n transform as any,\n toError,\n );\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, error }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, error };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n\n success: (...cases) => {\n const length = cases.length;\n return () => {\n const useTests = useEachAsync(func as any, transform);\n\n const _cases: any = cases.map(\n ({ invite: _invite, parameters, expected, test }, index) => {\n const invite = `#${toStringFlat(index + 1, length)} => ${_invite}`;\n const out = { invite, parameters, expected, test };\n return out;\n },\n );\n\n return useTests(..._cases);\n };\n },\n };\n};\n\n/**\n * Creates tests for function in a better way NB : We use strict-equality,\n * {@link useEach|see}\n *\n * @example\n * // ./add.ts\n * *export const add = (args: string[]) => args.reduce(\n * (acc, value) => {\n * acc+=value\n * return acc;\n * },\n * 0)\n *\n *\n * // .add.test.ts\n * *import { createTests } from '@bemedev/vitest-extended';\n * *import { add } from './add';\n *\n * *const useTests = createTests(add)\n *\n * *useTests(\n * {\n * invite: 'For : 1,2,3,4,5,6,7,8,9',\n * parameters: [[1, 2, 3, 4, 5, 6, 7, 8, 9]], // like this!\n * }\n * )\n *\n * @param library The test library\n * @param f The function to test\n * @param *\n * @returns A test.each like function to tests many cases NB: If the first\n * argument is an array, wrap the value in another array,\n */\nexport const createTests = <F0 extends any[], F1, F2 = F1>(\n func: Fn<F0, F1>,\n args?: {\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const { transform, toError } = args || {};\n return _create(func, transform, toError);\n};\n\ncreateTests.withImplementation = <F0 extends any[], F1, F2 = F1>(\n f: Fn<NoInfer<F0>, NoInfer<F1>>,\n {\n instanciation,\n name,\n transform,\n toError,\n }: {\n instanciation: () => Promise<Fn<F0, F1>> | Fn<F0, F1>;\n name: string;\n transform?: Fn<[Awaited<F1>], F2>;\n toError?: Fn<F0, string | undefined>;\n },\n) => {\n const func = vi.fn(f);\n\n if (instanciation) {\n beforeAll(async () => {\n const impl = await instanciation();\n func.mockImplementation(impl);\n });\n }\n\n return _create(func, transform, toError, name);\n};\n\ncreateTests.withoutImplementation = createTests;\n"],"mappings":";;;;;;AAeA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;CAClE,OAAO;EACL,mBAAmB,OAAO,MAAM,IAAI;EAEpC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;GAErB,aAAa;IAeX,OAdiB,kBACf,MACA,WACA,OAWY,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;KAGjD,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;KACzB;IACX,CAGsB,CAAC;GAC3B;EACF;EAEA,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;GACrB,aAAa;IAWX,OAViB,aAAa,MAAa,SAU7B,CAAC,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;KAG1D,OAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,MAAM,EAAE,MAAM;MACnC;MAAY;MAAU;KACnC;IACX,CAGsB,CAAC;GAC3B;EACF;CACF;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,CAAC;CACxC,OAAO,QAAQ,MAAM,WAAW,OAAO;AACzC;AAEA,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,CAAC;CAEpB,IAAI,eACF,UAAU,YAAY;EACpB,MAAM,OAAO,MAAM,cAAc;EACjC,KAAK,mBAAmB,IAAI;CAC9B,CAAC;CAGH,OAAO,QAAQ,MAAM,WAAW,SAAS,IAAI;AAC/C;AAEA,YAAY,wBAAwB"}
@@ -1,13 +1,9 @@
1
- import type { Fn } from "./bemedev/globals/types";
2
- import type { TestArgs, TestErrors } from "./types";
1
+ import type { Fn } from '../utils/bemedev/globals/types';
2
+ import type { TestArgs, TestErrors } from './types';
3
3
  type ReturnR<F extends Fn> = {
4
- acceptation: () => void;
5
- success: (...cases: TestArgs<F>) => () => void;
6
- fails: (...cases: TestErrors<F>) => () => void;
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: unknown;
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,3 +1,3 @@
1
- import type { _UseErrorEach_F, UseErrorEach_F } from "./error.types";
1
+ import type { _UseErrorEach_F, UseErrorEach_F } from './error.types';
2
2
  export declare const useErrorAsyncEachCases: _UseErrorEach_F;
3
3
  export declare const useErrorAsyncEach: UseErrorEach_F;
@@ -1,11 +1,5 @@
1
- import type { Fn } from "../bemedev/globals/types";
2
- import type { Identity, NextFn, TestErrors } from "../types";
1
+ import type { Fn } from '../../utils/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
- F extends Fn,
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 "./error";
2
- export * from "./pass";
1
+ export * from './error';
2
+ export * from './pass';
@@ -1,30 +1,30 @@
1
- import type { UseAsyncEach_F, UseEach_F } from "./pass.types";
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 "../bemedev/globals/types";
2
- import type { ChainedFn, Identity, NextFn, TestArgs } from "../types";
3
- export type _UseEach_F = <
4
- F extends Fn,
5
- T extends NextFn<F> = Identity<F>
6
- >(f: F, transform?: T, ...cases: TestArgs<ChainedFn<F, T>>) => void;
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 '../../utils/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 "vitest";
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
- withDefaultDelay: FakeWaiter2_F;
7
- all: FakeWaiter3_F;
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: unknown;
2
- export declare const defaultEquality: unknown;
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 "./acceptation";
2
- export * from "./createTests";
3
- export * from "./done";
4
- export * from "./each";
5
- export * from "./fakeWaiter";
6
- export * from "./types";
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
- {"version":3,"file":"isDefined.cjs","names":[],"sources":["../../src/vitest-extended/isDefined.ts"],"sourcesContent":["import type { Undefiny } from './bemedev/globals/types';\nexport type { Undefiny };\n\nexport const isDefined = <T>(value?: Undefiny<T>): value is T => {\n return value !== undefined && value !== null;\n};\n"],"mappings":";;AAGA,MAAa,aAAgB,UAAoC;CAC/D,OAAO,UAAU,KAAA,KAAa,UAAU;AAC1C"}
1
+ {"version":3,"file":"isDefined.cjs","names":[],"sources":["../../src/vitest-extended/isDefined.ts"],"sourcesContent":["import type { Undefiny } from '../utils/bemedev/globals/types';\nexport type { Undefiny };\n\nexport const isDefined = <T>(value?: Undefiny<T>): value is T => {\n return value !== undefined && value !== null;\n};\n"],"mappings":";;AAGA,MAAa,aAAgB,UAAoC;CAC/D,OAAO,UAAU,KAAA,KAAa,UAAU;AAC1C"}
@@ -1,3 +1,3 @@
1
- import type { Undefiny } from "./bemedev/globals/types";
1
+ import type { Undefiny } from '../utils/bemedev/globals/types';
2
2
  export type { Undefiny };
3
3
  export declare const isDefined: <T>(value?: Undefiny<T>) => value is T;
@@ -1 +1 @@
1
- {"version":3,"file":"isDefined.js","names":[],"sources":["../../src/vitest-extended/isDefined.ts"],"sourcesContent":["import type { Undefiny } from './bemedev/globals/types';\nexport type { Undefiny };\n\nexport const isDefined = <T>(value?: Undefiny<T>): value is T => {\n return value !== undefined && value !== null;\n};\n"],"mappings":";AAGA,MAAa,aAAgB,UAAoC;CAC/D,OAAO,UAAU,KAAA,KAAa,UAAU;AAC1C"}
1
+ {"version":3,"file":"isDefined.js","names":[],"sources":["../../src/vitest-extended/isDefined.ts"],"sourcesContent":["import type { Undefiny } from '../utils/bemedev/globals/types';\nexport type { Undefiny };\n\nexport const isDefined = <T>(value?: Undefiny<T>): value is T => {\n return value !== undefined && value !== null;\n};\n"],"mappings":";AAGA,MAAa,aAAgB,UAAoC;CAC/D,OAAO,UAAU,KAAA,KAAa,UAAU;AAC1C"}
@@ -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,2 @@
1
+ import { type UserWorkspaceConfig } from 'vitest/config';
2
+ export declare const defineProject: (conf: UserWorkspaceConfig) => import("vite").UserConfig;
@@ -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,3 +1,3 @@
1
- import type { ToArrayVitest_F, ToArray_F } from "./types";
1
+ import type { ToArrayVitest_F, ToArray_F } from './types';
2
2
  export declare const toArrayVitest: ToArrayVitest_F;
3
3
  export declare const toArray: ToArray_F;
@@ -1 +1 @@
1
- {"version":3,"file":"toStringFlat.cjs","names":[],"sources":["../../src/vitest-extended/toStringFlat.ts"],"sourcesContent":["import { type Fn } from './bemedev/globals/types';\n\nconst log10: Fn<[value: number], number> = (value: number) => {\n return Math.floor(Math.log10(value));\n};\n\nexport const toStringFlat: Fn<[value: number, len: number], string> = (\n _value,\n _len,\n) => {\n const logLength = log10(_len);\n const logValue = log10(_value);\n const length = logLength - logValue;\n\n let out = '';\n Array.from({ length }).forEach(() => {\n out += '0';\n });\n\n out += _value;\n\n return out;\n};\n"],"mappings":";;AAEA,MAAM,SAAsC,UAAkB;CAC5D,OAAO,KAAK,MAAM,KAAK,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,gBACX,QACA,SACG;CAGH,MAAM,SAFY,MAAM,IAED,IADN,MAAM,MACW;CAElC,IAAI,MAAM;CACV,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc;EACnC,OAAO;CACT,CAAC;CAED,OAAO;CAEP,OAAO;AACT"}
1
+ {"version":3,"file":"toStringFlat.cjs","names":[],"sources":["../../src/vitest-extended/toStringFlat.ts"],"sourcesContent":["import { type Fn } from '../utils/bemedev/globals/types';\n\nconst log10: Fn<[value: number], number> = (value: number) => {\n return Math.floor(Math.log10(value));\n};\n\nexport const toStringFlat: Fn<[value: number, len: number], string> = (\n _value,\n _len,\n) => {\n const logLength = log10(_len);\n const logValue = log10(_value);\n const length = logLength - logValue;\n\n let out = '';\n Array.from({ length }).forEach(() => {\n out += '0';\n });\n\n out += _value;\n\n return out;\n};\n"],"mappings":";;AAEA,MAAM,SAAsC,UAAkB;CAC5D,OAAO,KAAK,MAAM,KAAK,MAAM,KAAK,CAAC;AACrC;AAEA,MAAa,gBACX,QACA,SACG;CAGH,MAAM,SAFY,MAAM,IAED,IADN,MAAM,MACW;CAElC,IAAI,MAAM;CACV,MAAM,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,cAAc;EACnC,OAAO;CACT,CAAC;CAED,OAAO;CAEP,OAAO;AACT"}