@cloud-ru/ft-config-vitest 1.2.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # 1.3.0 (2026-01-22)
7
+
8
+
9
+ ### Features
10
+
11
+ * **FF-7732:** update vitest, add unitEnvironment param ([3b1f4a8](https://github.com/cloud-ru-tech/frontend-tools/commit/3b1f4a8a83913ad8f74ac9ea5feb0a9956dfd79e))
12
+
13
+
14
+
15
+
16
+
6
17
  ## 1.2.2 (2025-04-29)
7
18
 
8
19
 
@@ -1,6 +1,15 @@
1
- import { UserConfig } from 'vitest/config';
2
- type DefaultConfigOptions = {
1
+ import { type ViteUserConfig } from 'vitest/config';
2
+ type Options = {
3
+ /**
4
+ * Environment for unit tests.
5
+ * @default 'jsdom'
6
+ */
7
+ unitEnvironment?: 'node' | 'jsdom';
8
+ /**
9
+ * Whether to use aliases from `tsconfig.json` in root directory.
10
+ * @default true
11
+ */
3
12
  useAliases?: boolean;
4
13
  };
5
- declare const _default: (overrides?: UserConfig, options?: DefaultConfigOptions) => Record<string, any>;
6
- export default _default;
14
+ export default function (userConfig?: ViteUserConfig, { unitEnvironment, useAliases }?: Options): Record<string, any>;
15
+ export {};
package/dist/cjs/index.js CHANGED
@@ -3,22 +3,33 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.default = default_1;
6
7
  const path_1 = __importDefault(require("path"));
7
8
  const config_1 = require("vitest/config");
8
9
  const tsconfigPathsConverter_1 = require("./tsconfigPathsConverter");
9
- const getDefaultConfig = ({ useAliases = true }) => (0, config_1.defineConfig)({
10
- test: {
11
- snapshotFormat: {
12
- escapeString: true,
10
+ function default_1(userConfig, { unitEnvironment = 'jsdom', useAliases = true } = {}) {
11
+ return (0, config_1.mergeConfig)((0, config_1.defineConfig)({
12
+ resolve: {
13
+ alias: useAliases ? (0, tsconfigPathsConverter_1.tsconfigPathsConverter)(path_1.default.resolve(process.cwd(), 'tsconfig.json')) : undefined,
13
14
  },
14
- globals: true,
15
- include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
16
- environment: 'jsdom',
17
- outputFile: 'reports/unit/unit-report.xml',
18
- reporters: ['default', 'junit'],
19
- },
20
- resolve: {
21
- alias: useAliases ? (0, tsconfigPathsConverter_1.tsconfigPathsConverter)(path_1.default.resolve(process.cwd(), 'tsconfig.json')) : undefined,
22
- },
23
- });
24
- exports.default = (overrides = {}, options = {}) => (0, config_1.mergeConfig)(getDefaultConfig(options), overrides);
15
+ test: {
16
+ snapshotFormat: {
17
+ escapeString: true,
18
+ },
19
+ outputFile: 'reports/unit/unit-report.xml',
20
+ reporters: ['default', 'junit'],
21
+ projects: [
22
+ {
23
+ extends: true,
24
+ test: {
25
+ globals: true,
26
+ include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
27
+ exclude: ['**/dist/**', '**/node_modules/**', '**/*.browser.spec.(ts|tsx|js|jsx)'],
28
+ name: 'unit',
29
+ environment: unitEnvironment,
30
+ },
31
+ },
32
+ ],
33
+ },
34
+ }), userConfig !== null && userConfig !== void 0 ? userConfig : {});
35
+ }
@@ -1,6 +1,15 @@
1
- import { UserConfig } from 'vitest/config';
2
- type DefaultConfigOptions = {
1
+ import { type ViteUserConfig } from 'vitest/config';
2
+ type Options = {
3
+ /**
4
+ * Environment for unit tests.
5
+ * @default 'jsdom'
6
+ */
7
+ unitEnvironment?: 'node' | 'jsdom';
8
+ /**
9
+ * Whether to use aliases from `tsconfig.json` in root directory.
10
+ * @default true
11
+ */
3
12
  useAliases?: boolean;
4
13
  };
5
- declare const _default: (overrides?: UserConfig, options?: DefaultConfigOptions) => Record<string, any>;
6
- export default _default;
14
+ export default function (userConfig?: ViteUserConfig, { unitEnvironment, useAliases }?: Options): Record<string, any>;
15
+ export {};
package/dist/esm/index.js CHANGED
@@ -1,19 +1,29 @@
1
1
  import path from 'path';
2
2
  import { defineConfig, mergeConfig } from 'vitest/config';
3
3
  import { tsconfigPathsConverter } from './tsconfigPathsConverter';
4
- const getDefaultConfig = ({ useAliases = true }) => defineConfig({
5
- test: {
6
- snapshotFormat: {
7
- escapeString: true,
4
+ export default function (userConfig, { unitEnvironment = 'jsdom', useAliases = true } = {}) {
5
+ return mergeConfig(defineConfig({
6
+ resolve: {
7
+ alias: useAliases ? tsconfigPathsConverter(path.resolve(process.cwd(), 'tsconfig.json')) : undefined,
8
8
  },
9
- globals: true,
10
- include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
11
- environment: 'jsdom',
12
- outputFile: 'reports/unit/unit-report.xml',
13
- reporters: ['default', 'junit'],
14
- },
15
- resolve: {
16
- alias: useAliases ? tsconfigPathsConverter(path.resolve(process.cwd(), 'tsconfig.json')) : undefined,
17
- },
18
- });
19
- export default (overrides = {}, options = {}) => mergeConfig(getDefaultConfig(options), overrides);
9
+ test: {
10
+ snapshotFormat: {
11
+ escapeString: true,
12
+ },
13
+ outputFile: 'reports/unit/unit-report.xml',
14
+ reporters: ['default', 'junit'],
15
+ projects: [
16
+ {
17
+ extends: true,
18
+ test: {
19
+ globals: true,
20
+ include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
21
+ exclude: ['**/dist/**', '**/node_modules/**', '**/*.browser.spec.(ts|tsx|js|jsx)'],
22
+ name: 'unit',
23
+ environment: unitEnvironment,
24
+ },
25
+ },
26
+ ],
27
+ },
28
+ }), userConfig !== null && userConfig !== void 0 ? userConfig : {});
29
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud-ru/ft-config-vitest",
3
- "version": "1.2.2",
3
+ "version": "1.3.0",
4
4
  "author": {
5
5
  "name": "Nikita Karpenko",
6
6
  "url": "https://github.com/skaele"
@@ -11,9 +11,8 @@
11
11
  "description": "Config and dependencies for vitest",
12
12
  "license": "Apache-2.0",
13
13
  "dependencies": {
14
- "@vitest/coverage-v8": "3.1.2",
15
- "jsdom": "26.1.0",
16
- "vitest": "3.1.2"
14
+ "jsdom": "27.4.0",
15
+ "vitest": "4.0.17"
17
16
  },
18
17
  "types": "./dist/esm/index.d.ts",
19
18
  "exports": {
@@ -32,5 +31,5 @@
32
31
  "url": "https://github.com/cloud-ru-tech/frontend-tools.git",
33
32
  "directory": "packages/config-vitest"
34
33
  },
35
- "gitHead": "4695f07983373aabf7659a56ce23ac92a783c895"
34
+ "gitHead": "7acf6f92de482effb1f44feb8be4a92e867abecb"
36
35
  }
package/src/index.ts CHANGED
@@ -1,30 +1,48 @@
1
1
  import path from 'path';
2
2
 
3
- import { defineConfig, mergeConfig, UserConfig } from 'vitest/config';
3
+ import { defineConfig, mergeConfig, type ViteUserConfig } from 'vitest/config';
4
4
 
5
5
  import { tsconfigPathsConverter } from './tsconfigPathsConverter';
6
6
 
7
- type DefaultConfigOptions = {
7
+ type Options = {
8
+ /**
9
+ * Environment for unit tests.
10
+ * @default 'jsdom'
11
+ */
12
+ unitEnvironment?: 'node' | 'jsdom';
13
+ /**
14
+ * Whether to use aliases from `tsconfig.json` in root directory.
15
+ * @default true
16
+ */
8
17
  useAliases?: boolean;
9
18
  };
10
19
 
11
- const getDefaultConfig = ({ useAliases = true }: DefaultConfigOptions) =>
12
- defineConfig({
13
- test: {
14
- snapshotFormat: {
15
- escapeString: true,
20
+ export default function (userConfig?: ViteUserConfig, { unitEnvironment = 'jsdom', useAliases = true }: Options = {}) {
21
+ return mergeConfig(
22
+ defineConfig({
23
+ resolve: {
24
+ alias: useAliases ? tsconfigPathsConverter(path.resolve(process.cwd(), 'tsconfig.json')) : undefined,
16
25
  },
17
- globals: true,
18
- include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
19
-
20
- environment: 'jsdom',
21
- outputFile: 'reports/unit/unit-report.xml',
22
- reporters: ['default', 'junit'],
23
- },
24
- resolve: {
25
- alias: useAliases ? tsconfigPathsConverter(path.resolve(process.cwd(), 'tsconfig.json')) : undefined,
26
- },
27
- }) as UserConfig;
28
-
29
- export default (overrides: UserConfig = {}, options: DefaultConfigOptions = {}) =>
30
- mergeConfig(getDefaultConfig(options), overrides);
26
+ test: {
27
+ snapshotFormat: {
28
+ escapeString: true,
29
+ },
30
+ outputFile: 'reports/unit/unit-report.xml',
31
+ reporters: ['default', 'junit'],
32
+ projects: [
33
+ {
34
+ extends: true,
35
+ test: {
36
+ globals: true,
37
+ include: ['**/__tests__/**/*.spec.(ts|js|tsx|jsx)'],
38
+ exclude: ['**/dist/**', '**/node_modules/**', '**/*.browser.spec.(ts|tsx|js|jsx)'],
39
+ name: 'unit',
40
+ environment: unitEnvironment,
41
+ },
42
+ },
43
+ ],
44
+ },
45
+ }),
46
+ userConfig ?? {},
47
+ );
48
+ }