@bemedev/dev-utils 0.8.0 → 0.8.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 +12 -72
- package/lib/build-tests/addTarball.cjs.map +1 -1
- package/lib/build-tests/addTarball.js.map +1 -1
- package/lib/build-tests/buildPackageJson.cjs.map +1 -1
- package/lib/build-tests/buildPackageJson.js.map +1 -1
- package/lib/build-tests/cleanup.cjs.map +1 -1
- package/lib/build-tests/cleanup.js.map +1 -1
- package/lib/build-tests/cli/cli.cjs +1 -0
- package/lib/build-tests/cli/cli.cjs.map +1 -1
- package/lib/build-tests/cli/cli.js.map +1 -1
- package/lib/build-tests/cli/index.cjs +1 -0
- package/lib/build-tests/cli/index.cjs.map +1 -1
- package/lib/build-tests/cli/index.js.map +1 -1
- package/lib/build-tests/cli/post.cjs +1 -0
- package/lib/build-tests/cli/post.cjs.map +1 -1
- package/lib/build-tests/cli/post.js.map +1 -1
- package/lib/build-tests/cli/pre.cjs +1 -0
- package/lib/build-tests/cli/pre.cjs.map +1 -1
- package/lib/build-tests/cli/pre.js.map +1 -1
- package/lib/build-tests/cli/test.cjs.map +1 -1
- package/lib/build-tests/cli/test.js.map +1 -1
- package/lib/build-tests/constants.cjs.map +1 -1
- package/lib/build-tests/constants.js.map +1 -1
- package/lib/build-tests/getRelativePath.cjs +1 -0
- package/lib/build-tests/getRelativePath.cjs.map +1 -1
- package/lib/build-tests/getRelativePath.js.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.cjs +10 -2
- package/lib/build-tests/getTypescriptOutdir.cjs.map +1 -1
- package/lib/build-tests/getTypescriptOutdir.js +9 -2
- package/lib/build-tests/getTypescriptOutdir.js.map +1 -1
- package/lib/build-tests/import.cjs.map +1 -1
- package/lib/build-tests/import.js.map +1 -1
- package/lib/build-tests/imports/create.cjs +1 -0
- package/lib/build-tests/imports/create.cjs.map +1 -1
- package/lib/build-tests/imports/create.js.map +1 -1
- package/lib/build-tests/imports/helper.cjs +1 -0
- package/lib/build-tests/imports/helper.cjs.map +1 -1
- package/lib/build-tests/imports/helper.js.map +1 -1
- package/lib/build-tests/pack.cjs.map +1 -1
- package/lib/build-tests/pack.js.map +1 -1
- package/lib/rolldown-config/config.cjs +4 -3
- package/lib/rolldown-config/config.cjs.map +1 -1
- package/lib/rolldown-config/config.js +3 -3
- package/lib/rolldown-config/config.js.map +1 -1
- package/lib/rolldown-config/constants.cjs.map +1 -1
- package/lib/rolldown-config/constants.js.map +1 -1
- package/lib/rolldown-config/helpers.cjs +1 -0
- package/lib/rolldown-config/helpers.cjs.map +1 -1
- package/lib/rolldown-config/helpers.js.map +1 -1
- package/lib/rolldown-config/index.d.ts +1 -0
- package/lib/rolldown-config/input.cjs +1 -0
- package/lib/rolldown-config/input.cjs.map +1 -1
- package/lib/rolldown-config/input.js.map +1 -1
- package/lib/rolldown-config/output.cjs +2 -1
- package/lib/rolldown-config/output.cjs.map +1 -1
- package/lib/rolldown-config/output.d.ts +1 -1
- package/lib/rolldown-config/output.js +2 -1
- package/lib/rolldown-config/output.js.map +1 -1
- package/lib/rolldown-config/plugins/alias.cjs.map +1 -1
- package/lib/rolldown-config/plugins/alias.js.map +1 -1
- package/lib/rolldown-config/plugins/circulars.cjs +1 -0
- package/lib/rolldown-config/plugins/circulars.cjs.map +1 -1
- package/lib/rolldown-config/plugins/circulars.js.map +1 -1
- package/lib/rolldown-config/plugins/clean.cjs +10 -3
- package/lib/rolldown-config/plugins/clean.cjs.map +1 -1
- package/lib/rolldown-config/plugins/clean.d.ts +1 -1
- package/lib/rolldown-config/plugins/clean.js +8 -3
- package/lib/rolldown-config/plugins/clean.js.map +1 -1
- package/lib/rolldown-config/plugins/externals.cjs +1 -0
- package/lib/rolldown-config/plugins/externals.cjs.map +1 -1
- package/lib/rolldown-config/plugins/externals.js.map +1 -1
- package/lib/rolldown-config/plugins/index.cjs.map +1 -1
- package/lib/rolldown-config/plugins/index.d.ts +2 -2
- package/lib/rolldown-config/plugins/index.js.map +1 -1
- package/lib/rolldown-config/plugins/tsPaths.cjs.map +1 -1
- package/lib/rolldown-config/plugins/tsPaths.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.cjs +3 -1
- package/lib/rolldown-config/plugins/typescript.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.cjs.map +1 -1
- package/lib/rolldown-config/plugins/typescript.config.js.map +1 -1
- package/lib/rolldown-config/plugins/typescript.d.ts +1 -1
- package/lib/rolldown-config/plugins/typescript.js +3 -1
- package/lib/rolldown-config/plugins/typescript.js.map +1 -1
- package/lib/rolldown-config/utils.cjs.map +1 -1
- package/lib/rolldown-config/utils.js.map +1 -1
- package/lib/utils/sleep.cjs.map +1 -1
- package/lib/utils/sleep.js.map +1 -1
- package/lib/vitest-exclude/vitest.cjs +39 -14
- package/lib/vitest-exclude/vitest.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.d.ts +4 -3
- package/lib/vitest-exclude/vitest.js +39 -14
- package/lib/vitest-exclude/vitest.js.map +1 -1
- package/lib/vitest-exclude/vitest.utils.cjs +9 -8
- package/lib/vitest-exclude/vitest.utils.cjs.map +1 -1
- package/lib/vitest-exclude/vitest.utils.d.ts +4 -4
- package/lib/vitest-exclude/vitest.utils.js +8 -8
- package/lib/vitest-exclude/vitest.utils.js.map +1 -1
- package/lib/vitest-extended/acceptation.cjs +1 -0
- package/lib/vitest-extended/acceptation.cjs.map +1 -1
- package/lib/vitest-extended/acceptation.js.map +1 -1
- package/lib/vitest-extended/createTests.cjs +1 -0
- package/lib/vitest-extended/createTests.cjs.map +1 -1
- package/lib/vitest-extended/createTests.js.map +1 -1
- package/lib/vitest-extended/done.cjs +1 -0
- package/lib/vitest-extended/done.cjs.map +1 -1
- package/lib/vitest-extended/done.js.map +1 -1
- package/lib/vitest-extended/each/error.cjs +1 -0
- package/lib/vitest-extended/each/error.cjs.map +1 -1
- package/lib/vitest-extended/each/error.js.map +1 -1
- package/lib/vitest-extended/each/pass.cjs +1 -0
- package/lib/vitest-extended/each/pass.cjs.map +1 -1
- package/lib/vitest-extended/each/pass.js.map +1 -1
- package/lib/vitest-extended/fakeWaiter.cjs.map +1 -1
- package/lib/vitest-extended/fakeWaiter.js.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/coverage.js.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/partialCall.js.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/toUpper.js.map +1 -1
- package/lib/vitest-extended/fixtures/zod.cjs.map +1 -1
- package/lib/vitest-extended/fixtures/zod.js.map +1 -1
- package/lib/vitest-extended/identity.cjs +1 -0
- package/lib/vitest-extended/identity.cjs.map +1 -1
- package/lib/vitest-extended/identity.js.map +1 -1
- package/lib/vitest-extended/isDefined.cjs.map +1 -1
- package/lib/vitest-extended/isDefined.js.map +1 -1
- package/lib/vitest-extended/isFunction.cjs.map +1 -1
- package/lib/vitest-extended/isFunction.js.map +1 -1
- package/lib/vitest-extended/toArray.cjs.map +1 -1
- package/lib/vitest-extended/toArray.js.map +1 -1
- package/lib/vitest-extended/toStringFlat.cjs.map +1 -1
- package/lib/vitest-extended/toStringFlat.js.map +1 -1
- package/package.json +17 -59
- package/lib/vitest-alias/index.cjs +0 -4
- package/lib/vitest-alias/index.d.ts +0 -1
- package/lib/vitest-alias/index.js +0 -2
- package/lib/vitest-alias/vitest.cjs +0 -86
- package/lib/vitest-alias/vitest.cjs.map +0 -1
- package/lib/vitest-alias/vitest.d.ts +0 -33
- package/lib/vitest-alias/vitest.js +0 -82
- package/lib/vitest-alias/vitest.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\nimport { readTsConfig } from './typescript.config';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir
|
|
1
|
+
{"version":3,"file":"typescript.js","names":[],"sources":["../../../src/rolldown-config/plugins/typescript.ts"],"sourcesContent":["import { toArray } from '../utils';\nimport { existsSync } from 'node:fs';\nimport type { RolldownPluginOption } from 'rolldown';\nimport { replaceTscAliasPaths } from 'tsc-alias';\nimport ts from 'typescript';\nimport { readTsConfig } from './typescript.config';\nimport { DEFAULT_DIR } from '../constants';\n\ntype Props = {\n exclude?: string | string[];\n include?: Record<string, string>;\n declarationMap?: boolean;\n dir?: string;\n};\n\nexport const typescript = ({\n exclude,\n include,\n declarationMap,\n dir,\n}: Props = {}): RolldownPluginOption => {\n let done = false;\n\n return {\n name: 'bemedev-dts',\n options(opts) {\n const existing = toArray(opts.external).filter(\n v => typeof v === 'string' || v instanceof RegExp,\n );\n opts.external = [...existing, 'source-map-support'];\n return opts;\n },\n closeBundle: {\n order: 'pre',\n async handler() {\n if (done) return;\n const cwd = process.cwd();\n\n const tsconfigPath = ts.findConfigFile(\n cwd,\n existsSync,\n 'tsconfig.json',\n )!;\n\n const configFile = readTsConfig(tsconfigPath);\n const host = ts.createCompilerHost(configFile.options);\n const outDir = configFile.options.outDir ?? dir ?? DEFAULT_DIR;\n\n const parsed = ts.parseJsonConfigFileContent(\n {\n ...configFile,\n include,\n exclude: [...toArray(exclude), '*.ts'],\n compilerOptions: {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n },\n ts.sys,\n cwd,\n );\n\n const program = ts.createProgram(\n parsed.fileNames,\n {\n ...configFile.options,\n outDir,\n noEmit: false,\n emitDeclarationOnly: true,\n declaration: true,\n declarationMap,\n },\n host,\n );\n\n const emitResult = program.emit();\n\n const errors = ts\n .getPreEmitDiagnostics(program)\n .concat(emitResult.diagnostics)\n .filter(d => d.category === ts.DiagnosticCategory.Error);\n\n if (errors.length > 0) {\n console.error(\n ts.formatDiagnosticsWithColorAndContext(errors, host),\n );\n }\n\n await replaceTscAliasPaths({\n configFile: tsconfigPath,\n outDir,\n });\n\n done = true;\n console.log('DTS generation complete');\n },\n },\n };\n};\n"],"mappings":";;;;;;;AAeA,MAAa,cAAc,EACzB,SACA,SACA,gBACA,QACS,EAAE,KAA2B;CACtC,IAAI,OAAO;AAEX,QAAO;EACL,MAAM;EACN,QAAQ,MAAM;AAIZ,QAAK,WAAW,CAAC,GAHA,QAAQ,KAAK,SAAS,CAAC,QACtC,MAAK,OAAO,MAAM,YAAY,aAAa,OAEjB,EAAE,qBAAqB;AACnD,UAAO;;EAET,aAAa;GACX,OAAO;GACP,MAAM,UAAU;AACd,QAAI,KAAM;IACV,MAAM,MAAM,QAAQ,KAAK;IAEzB,MAAM,eAAe,GAAG,eACtB,KACA,YACA,gBACD;IAED,MAAM,aAAa,aAAa,aAAa;IAC7C,MAAM,OAAO,GAAG,mBAAmB,WAAW,QAAQ;IACtD,MAAM,SAAS,WAAW,QAAQ,UAAU,OAAA;IAE5C,MAAM,SAAS,GAAG,2BAChB;KACE,GAAG;KACH;KACA,SAAS,CAAC,GAAG,QAAQ,QAAQ,EAAE,OAAO;KACtC,iBAAiB;MACf,GAAG,WAAW;MACd;MACA,QAAQ;MACR,qBAAqB;MACrB,aAAa;MACb;MACD;KACF,EACD,GAAG,KACH,IACD;IAED,MAAM,UAAU,GAAG,cACjB,OAAO,WACP;KACE,GAAG,WAAW;KACd;KACA,QAAQ;KACR,qBAAqB;KACrB,aAAa;KACb;KACD,EACD,KACD;IAED,MAAM,aAAa,QAAQ,MAAM;IAEjC,MAAM,SAAS,GACZ,sBAAsB,QAAQ,CAC9B,OAAO,WAAW,YAAY,CAC9B,QAAO,MAAK,EAAE,aAAa,GAAG,mBAAmB,MAAM;AAE1D,QAAI,OAAO,SAAS,EAClB,SAAQ,MACN,GAAG,qCAAqC,QAAQ,KAAK,CACtD;AAGH,UAAM,qBAAqB;KACzB,YAAY;KACZ;KACD,CAAC;AAEF,WAAO;AACP,YAAQ,IAAI,0BAA0B;;GAEzC;EACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";;AAEA,MAAa,WAAqB,UAAS;
|
|
1
|
+
{"version":3,"file":"utils.cjs","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";;AAEA,MAAa,WAAqB,UAAS;AAGzC,KAFe,UAAU,KAAA,KAAa,UAAU,KAEpC,QAAO,EAAE;AACrB,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO;AAEjC,QAAO,CAAC,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";AAEA,MAAa,WAAqB,UAAS;
|
|
1
|
+
{"version":3,"file":"utils.js","names":[],"sources":["../../src/rolldown-config/utils.ts"],"sourcesContent":["import type { ToArray_F } from './types';\n\nexport const toArray: ToArray_F = value => {\n const check1 = value === undefined || value === null;\n\n if (check1) return [];\n if (Array.isArray(value)) return value;\n\n return [value];\n};\n"],"mappings":";AAEA,MAAa,WAAqB,UAAS;AAGzC,KAFe,UAAU,KAAA,KAAa,UAAU,KAEpC,QAAO,EAAE;AACrB,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO;AAEjC,QAAO,CAAC,MAAM"}
|
package/lib/utils/sleep.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;
|
|
1
|
+
{"version":3,"file":"sleep.cjs","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";;AAAA,MAAa,SAAS,OAAe;AACnC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
|
package/lib/utils/sleep.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;
|
|
1
|
+
{"version":3,"file":"sleep.js","names":[],"sources":["../../src/utils/sleep.ts"],"sourcesContent":["export const sleep = (ms: number) => {\n return new Promise(resolve => setTimeout(resolve, ms));\n};\n"],"mappings":";AAAA,MAAa,SAAS,OAAe;AACnC,QAAO,IAAI,SAAQ,YAAW,WAAW,SAAS,GAAG,CAAC"}
|
|
@@ -8,17 +8,17 @@ const require_vitest_exclude_constants = require("./constants.cjs");
|
|
|
8
8
|
* @param args Globs to ignore for test and coverage files
|
|
9
9
|
* @returns an object with includeTest and includeCoverage string arrays
|
|
10
10
|
*/
|
|
11
|
-
async function create(args = {}) {
|
|
11
|
+
async function create(args = {}, root) {
|
|
12
12
|
const firsts = {
|
|
13
|
-
patternTest: require_vitest_exclude_vitest_utils.testPattern(),
|
|
14
|
-
patternCov: require_vitest_exclude_vitest_utils.defaultCovPattern()
|
|
13
|
+
patternTest: require_vitest_exclude_vitest_utils.testPattern(root),
|
|
14
|
+
patternCov: require_vitest_exclude_vitest_utils.defaultCovPattern(root)
|
|
15
15
|
};
|
|
16
|
-
return create.withPattern(firsts, args);
|
|
16
|
+
return create.withPattern(firsts, args, root);
|
|
17
17
|
}
|
|
18
|
-
create.withPattern = async ({ patternTest
|
|
18
|
+
create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
|
|
19
19
|
return {
|
|
20
|
-
files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest, ignoreTestFiles),
|
|
21
|
-
coverage: await require_vitest_exclude_vitest_utils.buildInclude(patternCov, ignoreCoverageFiles)
|
|
20
|
+
files: await require_vitest_exclude_vitest_utils.buildInclude(patternTest ?? require_vitest_exclude_vitest_utils.testPattern(root), ignoreTestFiles, root),
|
|
21
|
+
coverage: await require_vitest_exclude_vitest_utils.buildInclude(patternCov ?? require_vitest_exclude_vitest_utils.defaultCovPattern(root), ignoreCoverageFiles, root)
|
|
22
22
|
};
|
|
23
23
|
};
|
|
24
24
|
/**
|
|
@@ -33,12 +33,36 @@ create.withPattern = async ({ patternTest = require_vitest_exclude_vitest_utils.
|
|
|
33
33
|
* The default search patter is './src/**\/*.ts'
|
|
34
34
|
*/
|
|
35
35
|
function exclude(args = {}) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
return {
|
|
37
|
+
name: require_vitest_exclude_constants.name,
|
|
38
|
+
enforce: "pre",
|
|
39
|
+
config: async (options) => {
|
|
40
|
+
const root = options?.root ?? process.cwd();
|
|
41
|
+
const testConfig = options?.test;
|
|
42
|
+
const coverage = options?.test?.coverage;
|
|
43
|
+
const patternCov = require_vitest_exclude_vitest_utils.defaultCovPattern(root);
|
|
44
|
+
const patternTest = require_vitest_exclude_vitest_utils.testPattern(root);
|
|
45
|
+
const { ignoreCoverageFiles, ignoreTestFiles } = args;
|
|
46
|
+
const all = await create.withPattern({
|
|
47
|
+
patternTest,
|
|
48
|
+
patternCov
|
|
49
|
+
}, {
|
|
50
|
+
ignoreCoverageFiles,
|
|
51
|
+
ignoreTestFiles
|
|
52
|
+
}, root);
|
|
53
|
+
return {
|
|
54
|
+
...options,
|
|
55
|
+
test: {
|
|
56
|
+
...testConfig,
|
|
57
|
+
include: all.files,
|
|
58
|
+
coverage: {
|
|
59
|
+
...coverage,
|
|
60
|
+
include: all.coverage
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
};
|
|
42
66
|
}
|
|
43
67
|
/**
|
|
44
68
|
* Plugin to add files with glob patterns to vitest
|
|
@@ -52,6 +76,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
52
76
|
name: require_vitest_exclude_constants.name,
|
|
53
77
|
enforce: "pre",
|
|
54
78
|
config: async (options) => {
|
|
79
|
+
const root = options?.root ?? process.cwd();
|
|
55
80
|
const testConfig = options?.test;
|
|
56
81
|
const coverage = options?.test?.coverage;
|
|
57
82
|
const all = await create.withPattern({
|
|
@@ -60,7 +85,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
60
85
|
}, {
|
|
61
86
|
ignoreCoverageFiles,
|
|
62
87
|
ignoreTestFiles
|
|
63
|
-
});
|
|
88
|
+
}, root);
|
|
64
89
|
return {
|
|
65
90
|
...options,
|
|
66
91
|
test: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { 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] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {
|
|
1
|
+
{"version":3,"file":"vitest.cjs","names":["testPattern","defaultCovPattern","buildInclude"],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\nimport type { Plugin } from 'vitest/config';\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 * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\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: {\n ...coverage,\n include: all.coverage,\n },\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: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;;AAeA,eAAsB,OAAO,OAAgB,EAAE,EAAE,MAAe;CAC9D,MAAM,SAAS;EACb,aAAaA,oCAAAA,YAAY,KAAK;EAC9B,YAAYC,oCAAAA,kBAAkB,KAAK;EACpC;AAED,QAAO,OAAO,YAAY,QAAQ,MAAM,KAAK;;AAG/C,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,EAAE,EAClD,EAAE,iBAAiB,wBAAiC,EAAE,EACtD,SACG;AAWH,QAAO;EAAE,OAAA,MAVWC,oCAAAA,aAClB,eAAeF,oCAAAA,YAAY,KAAK,EAChC,iBACA,KACD;EAMe,UAAA,MALOE,oCAAAA,aACrB,cAAcD,oCAAAA,kBAAkB,KAAK,EACrC,qBACA,KACD;EACyB;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;AAC1C,QAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAaA,oCAAAA,kBAAkB,KAAK;GAC1C,MAAM,cAAcD,oCAAAA,YAAY,KAAK;GAErC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ;;;;;;;;;AAUH,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;AACH,QAAO;EACL,MAAA,iCAAA;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { Args, WithPattern } from './types';
|
|
2
|
+
import type { Plugin } from 'vitest/config';
|
|
2
3
|
/**
|
|
3
4
|
* Create includeTest and includeCoverage arrays from glob patterns
|
|
4
5
|
*
|
|
5
6
|
* @param args Globs to ignore for test and coverage files
|
|
6
7
|
* @returns an object with includeTest and includeCoverage string arrays
|
|
7
8
|
*/
|
|
8
|
-
export declare function create(args?: Args[1]): Promise<{
|
|
9
|
+
export declare function create(args?: Args[1], root?: string): Promise<{
|
|
9
10
|
files: string[];
|
|
10
11
|
coverage: string[];
|
|
11
12
|
}>;
|
|
12
13
|
export declare namespace create {
|
|
13
|
-
var withPattern: ({ patternTest, patternCov
|
|
14
|
+
var withPattern: ({ patternTest, patternCov }?: Partial<Args[0]>, { ignoreTestFiles, ignoreCoverageFiles }?: Args[1], root?: string) => Promise<{
|
|
14
15
|
files: string[];
|
|
15
16
|
coverage: string[];
|
|
16
17
|
}>;
|
|
@@ -26,7 +27,7 @@ export declare namespace create {
|
|
|
26
27
|
* You don't have to use test.exclude.
|
|
27
28
|
* The default search patter is './src/**\/*.ts'
|
|
28
29
|
*/
|
|
29
|
-
export declare function exclude(args?: Args[1]):
|
|
30
|
+
export declare function exclude(args?: Args[1]): Plugin;
|
|
30
31
|
export declare namespace exclude {
|
|
31
32
|
var withPattern: WithPattern;
|
|
32
33
|
}
|
|
@@ -7,17 +7,17 @@ import { name } from "./constants.js";
|
|
|
7
7
|
* @param args Globs to ignore for test and coverage files
|
|
8
8
|
* @returns an object with includeTest and includeCoverage string arrays
|
|
9
9
|
*/
|
|
10
|
-
async function create(args = {}) {
|
|
10
|
+
async function create(args = {}, root) {
|
|
11
11
|
const firsts = {
|
|
12
|
-
patternTest: testPattern(),
|
|
13
|
-
patternCov: defaultCovPattern()
|
|
12
|
+
patternTest: testPattern(root),
|
|
13
|
+
patternCov: defaultCovPattern(root)
|
|
14
14
|
};
|
|
15
|
-
return create.withPattern(firsts, args);
|
|
15
|
+
return create.withPattern(firsts, args, root);
|
|
16
16
|
}
|
|
17
|
-
create.withPattern = async ({ patternTest
|
|
17
|
+
create.withPattern = async ({ patternTest, patternCov } = {}, { ignoreTestFiles, ignoreCoverageFiles } = {}, root) => {
|
|
18
18
|
return {
|
|
19
|
-
files: await buildInclude(patternTest, ignoreTestFiles),
|
|
20
|
-
coverage: await buildInclude(patternCov, ignoreCoverageFiles)
|
|
19
|
+
files: await buildInclude(patternTest ?? testPattern(root), ignoreTestFiles, root),
|
|
20
|
+
coverage: await buildInclude(patternCov ?? defaultCovPattern(root), ignoreCoverageFiles, root)
|
|
21
21
|
};
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
@@ -32,12 +32,36 @@ create.withPattern = async ({ patternTest = testPattern(), patternCov = defaultC
|
|
|
32
32
|
* The default search patter is './src/**\/*.ts'
|
|
33
33
|
*/
|
|
34
34
|
function exclude(args = {}) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
enforce: "pre",
|
|
38
|
+
config: async (options) => {
|
|
39
|
+
const root = options?.root ?? process.cwd();
|
|
40
|
+
const testConfig = options?.test;
|
|
41
|
+
const coverage = options?.test?.coverage;
|
|
42
|
+
const patternCov = defaultCovPattern(root);
|
|
43
|
+
const patternTest = testPattern(root);
|
|
44
|
+
const { ignoreCoverageFiles, ignoreTestFiles } = args;
|
|
45
|
+
const all = await create.withPattern({
|
|
46
|
+
patternTest,
|
|
47
|
+
patternCov
|
|
48
|
+
}, {
|
|
49
|
+
ignoreCoverageFiles,
|
|
50
|
+
ignoreTestFiles
|
|
51
|
+
}, root);
|
|
52
|
+
return {
|
|
53
|
+
...options,
|
|
54
|
+
test: {
|
|
55
|
+
...testConfig,
|
|
56
|
+
include: all.files,
|
|
57
|
+
coverage: {
|
|
58
|
+
...coverage,
|
|
59
|
+
include: all.coverage
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
};
|
|
41
65
|
}
|
|
42
66
|
/**
|
|
43
67
|
* Plugin to add files with glob patterns to vitest
|
|
@@ -51,6 +75,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
51
75
|
name,
|
|
52
76
|
enforce: "pre",
|
|
53
77
|
config: async (options) => {
|
|
78
|
+
const root = options?.root ?? process.cwd();
|
|
54
79
|
const testConfig = options?.test;
|
|
55
80
|
const coverage = options?.test?.coverage;
|
|
56
81
|
const all = await create.withPattern({
|
|
@@ -59,7 +84,7 @@ exclude.withPattern = (({ patternTest, patternCov }, { ignoreCoverageFiles, igno
|
|
|
59
84
|
}, {
|
|
60
85
|
ignoreCoverageFiles,
|
|
61
86
|
ignoreTestFiles
|
|
62
|
-
});
|
|
87
|
+
}, root);
|
|
63
88
|
return {
|
|
64
89
|
...options,
|
|
65
90
|
test: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { 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] = {}) {\n const firsts = {\n patternTest: testPattern(),\n patternCov: defaultCovPattern(),\n };\n\n return create.withPattern(firsts, args);\n}\n\ncreate.withPattern = async (\n {
|
|
1
|
+
{"version":3,"file":"vitest.js","names":[],"sources":["../../src/vitest-exclude/vitest.ts"],"sourcesContent":["import { name } from './constants';\nimport type { Args, WithPattern } from './types';\nimport {\n buildInclude,\n defaultCovPattern,\n testPattern,\n} from './vitest.utils';\nimport type { Plugin } from 'vitest/config';\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 * @param ignore globs to exclude inside\n * @returns a vitest config\n *\n * @see {@link exclude.withPattern}\n * @remarks\n * You don't have to use test.exclude.\n * The default search patter is './src/**\\/*.ts'\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: {\n ...coverage,\n include: all.coverage,\n },\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: {\n ...coverage,\n include: all.coverage,\n },\n },\n };\n },\n };\n}) as WithPattern;\n"],"mappings":";;;;;;;;;AAeA,eAAsB,OAAO,OAAgB,EAAE,EAAE,MAAe;CAC9D,MAAM,SAAS;EACb,aAAa,YAAY,KAAK;EAC9B,YAAY,kBAAkB,KAAK;EACpC;AAED,QAAO,OAAO,YAAY,QAAQ,MAAM,KAAK;;AAG/C,OAAO,cAAc,OACnB,EAAE,aAAa,eAAiC,EAAE,EAClD,EAAE,iBAAiB,wBAAiC,EAAE,EACtD,SACG;AAWH,QAAO;EAAE,OAAA,MAVW,aAClB,eAAe,YAAY,KAAK,EAChC,iBACA,KACD;EAMe,UAAA,MALO,aACrB,cAAc,kBAAkB,KAAK,EACrC,qBACA,KACD;EACyB;;;;;;;;;;;;;AAc5B,SAAgB,QAAQ,OAAgB,EAAE,EAAE;AAC1C,QAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,aAAa,kBAAkB,KAAK;GAC1C,MAAM,cAAc,YAAY,KAAK;GAErC,MAAM,EAAE,qBAAqB,oBAAoB;GAEjD,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ;;;;;;;;;AAUH,QAAQ,gBACN,EAAE,aAAa,cACf,EAAE,qBAAqB,sBACpB;AACH,QAAO;EACL;EACA,SAAS;EACT,QAAQ,OAAM,YAAW;GACvB,MAAM,OAAO,SAAS,QAAQ,QAAQ,KAAK;GAC3C,MAAM,aAAa,SAAS;GAC5B,MAAM,WAAW,SAAS,MAAM;GAEhC,MAAM,MAAM,MAAM,OAAO,YACvB;IAAE;IAAa;IAAY,EAC3B;IAAE;IAAqB;IAAiB,EACxC,KACD;AAED,UAAO;IACL,GAAG;IACH,MAAM;KACJ,GAAG;KACH,SAAS,IAAI;KACb,UAAU;MACR,GAAG;MACH,SAAS,IAAI;MACd;KACF;IACF;;EAEJ"}
|
|
@@ -1,25 +1,26 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
let fs = require("fs");
|
|
3
4
|
let glob = require("glob");
|
|
4
5
|
let path = require("path");
|
|
5
6
|
//#region src/vitest-exclude/vitest.utils.ts
|
|
6
|
-
const hasSrc = () => {
|
|
7
|
-
return (0, fs.existsSync)((0, path.join)(
|
|
7
|
+
const hasSrc = (root = process.cwd()) => {
|
|
8
|
+
return (0, fs.existsSync)((0, path.join)(root, "src"));
|
|
8
9
|
};
|
|
9
|
-
const defaultCovPattern = () => {
|
|
10
|
+
const defaultCovPattern = (root) => {
|
|
10
11
|
/* v8 ignore next */
|
|
11
|
-
return `${hasSrc() ? "src/" : ""}**/*.t{s,sx}`;
|
|
12
|
+
return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
|
|
12
13
|
};
|
|
13
14
|
const mapper = (str) => str.replace(/\\/g, "/");
|
|
14
|
-
const buildInclude = async (pattern, ignore) => {
|
|
15
|
+
const buildInclude = async (pattern, ignore, root = process.cwd()) => {
|
|
15
16
|
return (await (0, glob.glob)(pattern, {
|
|
16
17
|
ignore,
|
|
17
|
-
cwd:
|
|
18
|
+
cwd: root
|
|
18
19
|
})).map(mapper).sort();
|
|
19
20
|
};
|
|
20
|
-
const testPattern = () => {
|
|
21
|
+
const testPattern = (root) => {
|
|
21
22
|
/* v8 ignore next */
|
|
22
|
-
return `${hasSrc() ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
23
|
+
return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
23
24
|
};
|
|
24
25
|
//#endregion
|
|
25
26
|
exports.buildInclude = buildInclude;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = () => {\n return existsSync(join(
|
|
1
|
+
{"version":3,"file":"vitest.utils.cjs","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, {\n ignore,\n cwd: root,\n });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;;;AAIA,MAAa,UAAU,OAAO,QAAQ,KAAK,KAAK;AAC9C,SAAA,GAAA,GAAA,aAAA,GAAA,KAAA,MAAuB,MAAM,MAAM,CAAC;;AAGtC,MAAa,qBAAqB,SAAkB;;AAGlD,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG;;AAG/B,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,IAAI;AACvD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,KAAK,KACjB;AAMH,SAAO,OAAA,GAAA,KAAA,MALoB,SAAS;EAClC;EACA,KAAK;EACN,CAAC,EAEa,IAAI,OAAO,CAAC,MAAM;;AAGnC,MAAa,eAAe,SAAkB;;AAG5C,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const hasSrc: () => boolean;
|
|
2
|
-
export declare const defaultCovPattern: () => string;
|
|
3
|
-
export declare const buildInclude: (pattern: string | string[], ignore?: string[]) => Promise<string[]>;
|
|
4
|
-
export declare const testPattern: () => string;
|
|
1
|
+
export declare const hasSrc: (root?: string) => boolean;
|
|
2
|
+
export declare const defaultCovPattern: (root?: string) => string;
|
|
3
|
+
export declare const buildInclude: (pattern: string | string[], ignore?: string[], root?: string) => Promise<string[]>;
|
|
4
|
+
export declare const testPattern: (root?: string) => string;
|
|
@@ -2,23 +2,23 @@ import { existsSync } from "fs";
|
|
|
2
2
|
import { glob } from "glob";
|
|
3
3
|
import { join } from "path";
|
|
4
4
|
//#region src/vitest-exclude/vitest.utils.ts
|
|
5
|
-
const hasSrc = () => {
|
|
6
|
-
return existsSync(join(
|
|
5
|
+
const hasSrc = (root = process.cwd()) => {
|
|
6
|
+
return existsSync(join(root, "src"));
|
|
7
7
|
};
|
|
8
|
-
const defaultCovPattern = () => {
|
|
8
|
+
const defaultCovPattern = (root) => {
|
|
9
9
|
/* v8 ignore next */
|
|
10
|
-
return `${hasSrc() ? "src/" : ""}**/*.t{s,sx}`;
|
|
10
|
+
return `${hasSrc(root) ? "src/" : ""}**/*.t{s,sx}`;
|
|
11
11
|
};
|
|
12
12
|
const mapper = (str) => str.replace(/\\/g, "/");
|
|
13
|
-
const buildInclude = async (pattern, ignore) => {
|
|
13
|
+
const buildInclude = async (pattern, ignore, root = process.cwd()) => {
|
|
14
14
|
return (await glob(pattern, {
|
|
15
15
|
ignore,
|
|
16
|
-
cwd:
|
|
16
|
+
cwd: root
|
|
17
17
|
})).map(mapper).sort();
|
|
18
18
|
};
|
|
19
|
-
const testPattern = () => {
|
|
19
|
+
const testPattern = (root) => {
|
|
20
20
|
/* v8 ignore next */
|
|
21
|
-
return `${hasSrc() ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
21
|
+
return `${hasSrc(root) ? "src/" : ""}**/*.{test,spec}.{ts,js,tsx,jsx}`;
|
|
22
22
|
};
|
|
23
23
|
//#endregion
|
|
24
24
|
export { buildInclude, defaultCovPattern, hasSrc, testPattern };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = () => {\n return existsSync(join(
|
|
1
|
+
{"version":3,"file":"vitest.utils.js","names":[],"sources":["../../src/vitest-exclude/vitest.utils.ts"],"sourcesContent":["import { existsSync } from 'fs';\nimport { glob } from 'glob';\nimport { join } from 'node:path';\n\nexport const hasSrc = (root = process.cwd()) => {\n return existsSync(join(root, 'src'));\n};\n\nexport const defaultCovPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.t{s,sx}`;\n};\n\nconst mapper = (str: string) => str.replace(/\\\\/g, '/');\nexport const buildInclude = async (\n pattern: string | string[],\n ignore?: string[],\n root = process.cwd(),\n) => {\n const include = await glob(pattern, {\n ignore,\n cwd: root,\n });\n\n return include.map(mapper).sort();\n};\n\nexport const testPattern = (root?: string) => {\n const _src = hasSrc(root);\n /* v8 ignore next */\n return `${_src ? 'src/' : ''}**/*.{test,spec}.{ts,js,tsx,jsx}`;\n};\n"],"mappings":";;;;AAIA,MAAa,UAAU,OAAO,QAAQ,KAAK,KAAK;AAC9C,QAAO,WAAW,KAAK,MAAM,MAAM,CAAC;;AAGtC,MAAa,qBAAqB,SAAkB;;AAGlD,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG;;AAG/B,MAAM,UAAU,QAAgB,IAAI,QAAQ,OAAO,IAAI;AACvD,MAAa,eAAe,OAC1B,SACA,QACA,OAAO,QAAQ,KAAK,KACjB;AAMH,SAAO,MALe,KAAK,SAAS;EAClC;EACA,KAAK;EACN,CAAC,EAEa,IAAI,OAAO,CAAC,MAAM;;AAGnC,MAAa,eAAe,SAAkB;;AAG5C,QAAO,GAFM,OAAO,KAEN,GAAG,SAAS,GAAG"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
const require_vitest_extended_isFunction = require("./isFunction.cjs");
|
|
3
4
|
let vitest = require("vitest");
|
|
4
5
|
//#region src/vitest-extended/acceptation.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import type { Fn } from './bemedev/globals/types';\nimport { expect, test } from 'vitest';\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/**\n * For test only\n * useTestFunctionAcceptation\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"acceptation.cjs","names":["isFunction"],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import type { Fn } from './bemedev/globals/types';\nimport { expect, test } from 'vitest';\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/**\n * For test only\n * useTestFunctionAcceptation\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;;;AAIA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;AAExB,EAAA,GAAA,OAAA,MAAK,UAAU,KAAK,oBAAoB;AACtC,GAAA,GAAA,OAAA,QAAO,EAAE,CAAC,aAAa;GACvB;AACF,EAAA,GAAA,OAAA,MAAK,UAAU,KAAK,uBAAuB;AAEzC,GAAA,GAAA,OAAA,QADcA,mCAAAA,WAAW,EACb,CAAC,CAAC,KAAK,KAAK;GACxB;;;;;;AAOJ,MAAa,SAAS"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import type { Fn } from './bemedev/globals/types';\nimport { expect, test } from 'vitest';\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/**\n * For test only\n * useTestFunctionAcceptation\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAIA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;
|
|
1
|
+
{"version":3,"file":"acceptation.js","names":[],"sources":["../../src/vitest-extended/acceptation.ts"],"sourcesContent":["import type { Fn } from './bemedev/globals/types';\nimport { expect, test } from 'vitest';\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/**\n * For test only\n * useTestFunctionAcceptation\n */\nexport const useTFA = useTestFunctionAcceptation;\n"],"mappings":";;;AAIA,MAAa,8BAA8B,GAAO,UAAmB;CACnE,MAAM,OAAO,SAAS,EAAE;AAExB,MAAK,UAAU,KAAK,oBAAoB;AACtC,SAAO,EAAE,CAAC,aAAa;GACvB;AACF,MAAK,UAAU,KAAK,uBAAuB;AAEzC,SADc,WAAW,EACb,CAAC,CAAC,KAAK,KAAK;GACxB;;;;;;AAOJ,MAAa,SAAS"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
const require_vitest_extended_toStringFlat = require("./toStringFlat.cjs");
|
|
3
4
|
const require_vitest_extended_acceptation = require("./acceptation.cjs");
|
|
4
5
|
const require_vitest_extended_each_error = require("./each/error.cjs");
|
|
@@ -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';\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\n * NB : We use strict-equality, {@link useEach|see}\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\n *\n * NB: If the first argument is an array, wrap the value in another array,\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 */\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":"
|
|
1
|
+
{"version":3,"file":"createTests.cjs","names":["useTFA","useErrorAsyncEach","toStringFlat","useEachAsync","vi"],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\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\n * NB : We use strict-equality, {@link useEach|see}\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\n *\n * NB: If the first argument is an array, wrap the value in another array,\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 */\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":";;;;;;;;AAcA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;AAClE,QAAO;EACL,mBAAmBA,oCAAAA,OAAO,MAAM,KAAK;EAErC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;AAErB,gBAAa;AAeX,WAdiBC,mCAAAA,kBACf,MACA,WACA,QAWa,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;AAGjD,YAAO;MADO,QAAA,IADKC,qCAAAA,aAAa,QAAQ,GAAG,OAAO,CAAC,MAAM;MACnC;MAAY;MACxB;MAIW,CAAC;;;EAI9B,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;AACrB,gBAAa;AAWX,WAViBC,kCAAAA,aAAa,MAAa,UAU5B,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;AAG1D,YAAO;MADO,QAAA,IADKD,qCAAAA,aAAa,QAAQ,GAAG,OAAO,CAAC,MAAM;MACnC;MAAY;MAAU;MAClC;MAIW,CAAC;;;EAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCH,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,EAAE;AACzC,QAAO,QAAQ,MAAM,WAAW,QAAQ;;AAG1C,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAOE,OAAAA,GAAG,GAAG,EAAE;AAErB,KAAI,cACF,EAAA,GAAA,OAAA,WAAU,YAAY;EACpB,MAAM,OAAO,MAAM,eAAe;AAClC,OAAK,mBAAmB,KAAK;GAC7B;AAGJ,QAAO,QAAQ,MAAM,WAAW,SAAS,KAAK;;AAGhD,YAAY,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\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\n * NB : We use strict-equality, {@link useEach|see}\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\n *\n * NB: If the first argument is an array, wrap the value in another array,\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 */\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":";;;;;;AAcA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;
|
|
1
|
+
{"version":3,"file":"createTests.js","names":[],"sources":["../../src/vitest-extended/createTests.ts"],"sourcesContent":["import { beforeAll, vi } from 'vitest';\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\n * NB : We use strict-equality, {@link useEach|see}\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\n *\n * NB: If the first argument is an array, wrap the value in another array,\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 */\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":";;;;;;AAcA,MAAM,WAA2B,MAAM,WAAW,SAAS,SAAS;AAClE,QAAO;EACL,mBAAmB,OAAO,MAAM,KAAK;EAErC,QAAQ,GAAG,UAAU;GACnB,MAAM,SAAS,MAAM;AAErB,gBAAa;AAeX,WAdiB,kBACf,MACA,WACA,QAWa,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,SAAS,UAAU;AAGjD,YAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,OAAO,CAAC,MAAM;MACnC;MAAY;MACxB;MAIW,CAAC;;;EAI9B,UAAU,GAAG,UAAU;GACrB,MAAM,SAAS,MAAM;AACrB,gBAAa;AAWX,WAViB,aAAa,MAAa,UAU5B,CAAC,GARI,MAAM,KACvB,EAAE,QAAQ,SAAS,YAAY,UAAU,QAAQ,UAAU;AAG1D,YAAO;MADO,QAAA,IADK,aAAa,QAAQ,GAAG,OAAO,CAAC,MAAM;MACnC;MAAY;MAAU;MAClC;MAIW,CAAC;;;EAG/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCH,MAAa,eACX,MACA,SAIG;CACH,MAAM,EAAE,WAAW,YAAY,QAAQ,EAAE;AACzC,QAAO,QAAQ,MAAM,WAAW,QAAQ;;AAG1C,YAAY,sBACV,GACA,EACE,eACA,MACA,WACA,cAOC;CACH,MAAM,OAAO,GAAG,GAAG,EAAE;AAErB,KAAI,cACF,WAAU,YAAY;EACpB,MAAM,OAAO,MAAM,eAAe;AAClC,OAAK,mBAAmB,KAAK;GAC7B;AAGJ,QAAO,QAAQ,MAAM,WAAW,SAAS,KAAK;;AAGhD,YAAY,wBAAwB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { sleep } from '../utils/sleep';\nimport { expect, test, type TestOptions } from 'vitest';\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"done.cjs","names":["sleep","test"],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { sleep } from '../utils/sleep';\nimport { expect, test, type TestOptions } from 'vitest';\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;;;AAIA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;AAC3B,QAAMA,oBAAAA,MAAM,GAAG;AACf,GAAA,GAAA,OAAA,QAAO,SAAS,CAAC,KAAK,KAAK;;AAG7B,QAAO;EAAE;EAAM;EAAU;;AAG3B,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,GAAG;AAG5C,MAAM,cAAc,YAAmC;AACrD,KAAI,OAAO,YAAY,SAAU,QAAO,OAAO,QAAQ;AACvD,QAAO,OAAO,SAAS,QAAQ;;AAGjC,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,QAAQ;CACpC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,SAAS;AAC1B,KAAI,EAAE,OAAO,YAAY,UACvB,YAAW;EAAE,GAAG;EAAS;EAAS;AAGpC,QAAO,CAAC,UAAU,SAAS;;;;;;;;;AAW7B,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,SAAA,GAAA,OAAA,MAAY,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB;;;;;;;;;AAUJ,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,QAAOC,OAAAA,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB;;;;;;;;;AAUJ,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,QAAOA,OAAAA,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { sleep } from '../utils/sleep';\nimport { expect, test, type TestOptions } from 'vitest';\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;AAIA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;
|
|
1
|
+
{"version":3,"file":"done.js","names":[],"sources":["../../src/vitest-extended/done.ts"],"sourcesContent":["import { sleep } from '../utils/sleep';\nimport { expect, test, type TestOptions } from 'vitest';\nimport type { TestDoneFunction } from './types';\n\nconst useDone = (ms = 0) => {\n let executed = false;\n const done = () => (executed = true);\n\n const testDone = async () => {\n await sleep(ms);\n expect(executed).toBe(true);\n };\n\n return { done, testDone };\n};\n\nconst min100 = (ms = 0) => Math.max(100, ms);\n\n// #region Preparation\nconst getTimeout = (options?: TestOptions | number) => {\n if (typeof options === 'number') return min100(options);\n return min100(options?.timeout);\n};\n\nconst objectify = (\n options?: TestOptions | number,\n): [TestOptions, number] => {\n const _timeout = getTimeout(options);\n const timeout = _timeout + 100;\n\n let _options = { timeout };\n if (!(typeof options === 'number')) {\n _options = { ...options, timeout };\n }\n\n return [_options, _timeout];\n};\n// #endregion\n\n/**\n * Build a test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\nexport const doneTest = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a test that fails with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.fails = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.fails(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n\n/**\n * Build a concurrent test with a done function with a timeout\n * @param invite The description of the test\n * @param fn Where you can test, Don't async this function\n * @param options Options for the test like TestAPI from vitest\n * @returns a vitest test\n */\ndoneTest.concurrent = (\n invite: string,\n fn: TestDoneFunction,\n options: number | TestOptions = 100,\n) => {\n const [_options, ms] = objectify(options);\n\n return test.concurrent(invite, _options, () => {\n const { done, testDone } = useDone(ms);\n fn(done);\n return testDone();\n });\n};\n"],"mappings":";;;AAIA,MAAM,WAAW,KAAK,MAAM;CAC1B,IAAI,WAAW;CACf,MAAM,aAAc,WAAW;CAE/B,MAAM,WAAW,YAAY;AAC3B,QAAM,MAAM,GAAG;AACf,SAAO,SAAS,CAAC,KAAK,KAAK;;AAG7B,QAAO;EAAE;EAAM;EAAU;;AAG3B,MAAM,UAAU,KAAK,MAAM,KAAK,IAAI,KAAK,GAAG;AAG5C,MAAM,cAAc,YAAmC;AACrD,KAAI,OAAO,YAAY,SAAU,QAAO,OAAO,QAAQ;AACvD,QAAO,OAAO,SAAS,QAAQ;;AAGjC,MAAM,aACJ,YAC0B;CAC1B,MAAM,WAAW,WAAW,QAAQ;CACpC,MAAM,UAAU,WAAW;CAE3B,IAAI,WAAW,EAAE,SAAS;AAC1B,KAAI,EAAE,OAAO,YAAY,UACvB,YAAW;EAAE,GAAG;EAAS;EAAS;AAGpC,QAAO,CAAC,UAAU,SAAS;;;;;;;;;AAW7B,MAAa,YACX,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,QAAO,KAAK,QAAQ,gBAAgB;EAClC,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB;;;;;;;;;AAUJ,SAAS,SACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,QAAO,KAAK,MAAM,QAAQ,gBAAgB;EACxC,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB;;;;;;;;;AAUJ,SAAS,cACP,QACA,IACA,UAAgC,QAC7B;CACH,MAAM,CAAC,UAAU,MAAM,UAAU,QAAQ;AAEzC,QAAO,KAAK,WAAW,QAAQ,gBAAgB;EAC7C,MAAM,EAAE,MAAM,aAAa,QAAQ,GAAG;AACtC,KAAG,KAAK;AACR,SAAO,UAAU;GACjB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
const require_vitest_extended_toArray = require("../toArray.cjs");
|
|
3
4
|
const require_vitest_extended_identity = require("../identity.cjs");
|
|
4
5
|
let vitest = require("vitest");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.cjs","names":["identity","toArrayVitest"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"error.cjs","names":["identity","toArrayVitest"],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;;;AAKA,MAAa,0BACX,GACA,YAAYA,iCAAAA,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;AACH,QAAA,KAAK,WAAW,KAAKC,gCAAAA,cAAc,MAAM,MAAM,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;AAEzB,UAAO,UAAU,MADC,EAAE,GAAG,KAAK,CACP;;EAGvB,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,KAAK,GAAG;AAEzC,SAAA,GAAA,OAAA,QAAa,OAAO,CAAC,QAAQ,aAAa,MAAM;GAEnD;;AAGH,MAAa,qBACX,GACA,WACA,YACG;AACH,SAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;AAKA,MAAa,0BACX,GACA,YAAY,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;
|
|
1
|
+
{"version":3,"file":"error.js","names":[],"sources":["../../../src/vitest-extended/each/error.ts"],"sourcesContent":["import { expect, test } from 'vitest';\nimport { identity } from '../identity';\nimport { toArrayVitest } from '../toArray';\nimport type { _UseErrorEach_F, UseErrorEach_F } from './error.types';\n\nexport const useErrorAsyncEachCases: _UseErrorEach_F = (\n f,\n transform = identity as any,\n toError = () => undefined,\n ...cases\n) => {\n test.concurrent.each(toArrayVitest.error(cases))(\n '%s',\n async (_, args, _error) => {\n const actual = async () => {\n const out = await f(...args);\n return transform(out);\n };\n const check = _error === undefined;\n const error = check ? toError(...args) : _error;\n\n await expect(actual).rejects.toThrowError(error);\n },\n );\n};\n\nexport const useErrorAsyncEach: UseErrorEach_F = (\n f,\n transform,\n toError,\n) => {\n return (...cases) =>\n useErrorAsyncEachCases(f, transform, toError, ...cases);\n};\n"],"mappings":";;;;AAKA,MAAa,0BACX,GACA,YAAY,UACZ,gBAAgB,KAAA,GAChB,GAAG,UACA;AACH,MAAK,WAAW,KAAK,cAAc,MAAM,MAAM,CAAC,CAC9C,MACA,OAAO,GAAG,MAAM,WAAW;EACzB,MAAM,SAAS,YAAY;AAEzB,UAAO,UAAU,MADC,EAAE,GAAG,KAAK,CACP;;EAGvB,MAAM,QADQ,WAAW,KAAA,IACH,QAAQ,GAAG,KAAK,GAAG;AAEzC,QAAM,OAAO,OAAO,CAAC,QAAQ,aAAa,MAAM;GAEnD;;AAGH,MAAa,qBACX,GACA,WACA,YACG;AACH,SAAQ,GAAG,UACT,uBAAuB,GAAG,WAAW,SAAS,GAAG,MAAM"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
3
|
const require_vitest_extended_toArray = require("../toArray.cjs");
|
|
3
4
|
const require_vitest_extended_identity = require("../identity.cjs");
|
|
4
5
|
let vitest = require("vitest");
|