@rsdk/jest 5.16.0 → 5.17.0-next.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.
@@ -0,0 +1,18 @@
1
+ const ts = require('typescript');
2
+
3
+ // ts-jest кеширует настройки на весь проект и не применяет allowJs для
4
+ // отдельного пути, поэтому ESM-only зависимости транспилируются здесь
5
+ module.exports = {
6
+ process(sourceText, sourcePath) {
7
+ const { outputText } = ts.transpileModule(sourceText, {
8
+ fileName: sourcePath,
9
+ compilerOptions: {
10
+ allowJs: true,
11
+ module: ts.ModuleKind.CommonJS,
12
+ target: ts.ScriptTarget.ES2022,
13
+ },
14
+ });
15
+
16
+ return { code: outputText };
17
+ },
18
+ };
package/jest.config.js CHANGED
@@ -1,13 +1,25 @@
1
- let prettierPath;
2
-
3
- try {
4
- // for work with jest snapshot
5
- prettierPath = require.resolve('jest-prettier');
6
- } catch {}
1
+ // Зависимости Fastify, которые поставляются только как ESM. Jest их не умеет
2
+ // загружать через require, поэтому их приходится транспилировать
3
+ const esmOnlyPackages = 'content-disposition|cookie';
7
4
 
8
5
  /** @type {import('ts-jest').JestConfigWithTsJest} */
9
6
  let config = {
10
- preset: 'ts-jest',
7
+ transform: {
8
+ '^.+\\.tsx?$': [
9
+ 'ts-jest',
10
+ {
11
+ // С `module: nodenext` ts-jest жалуется на hybrid module kind,
12
+ // полная проверка типов в тестах для этого не нужна
13
+ diagnostics: { ignoreCodes: [151002] },
14
+ },
15
+ ],
16
+ [`/node_modules/(${esmOnlyPackages})/.+\\.js$`]: require.resolve(
17
+ './esm-only.transformer',
18
+ ),
19
+ },
20
+ transformIgnorePatterns: [
21
+ `^(?!.*/node_modules/(${esmOnlyPackages})/).*/node_modules/`,
22
+ ],
11
23
  testEnvironment: 'node',
12
24
  testMatch: [
13
25
  '**/?(*.)+(spec|test).[jt]s?(x)',
@@ -15,8 +27,5 @@ let config = {
15
27
  ],
16
28
  setupFiles: ['dotenv/config'],
17
29
  };
18
- if (prettierPath) {
19
- config.prettierPath = prettierPath;
20
- }
21
30
 
22
31
  module.exports = config;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@rsdk/jest",
3
- "version": "5.16.0",
3
+ "version": "5.17.0-next.0",
4
4
  "description": "Jest configuration presets",
5
5
  "license": "ISC",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
9
9
  "peerDependencies": {
10
- "@types/jest": "^29.5.14",
11
- "jest": "^29.7.0"
10
+ "@types/jest": "^30.0.0",
11
+ "jest": "^30.4.0"
12
12
  },
13
- "gitHead": "6815c6f20a183c919cf4b01a3b61bc381b4321c6"
13
+ "gitHead": "c65206299ce1f0f1e209bb936721a1537bc4a064"
14
14
  }