Przeglądaj źródła

chore: omg all tests pass after adding the swc jest and import compat resolver

benduran 2 tygodni temu
rodzic
commit
7977030f03

+ 3 - 5
apps/hermes/client/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 1
apps/hermes/client/js/package.json

@@ -38,6 +38,7 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@types/jest": "^29.4.0",
     "@types/node": "^20.14.2",
     "@types/yargs": "^17.0.10",
@@ -45,7 +46,6 @@
     "jest": "^29.4.0",
     "openapi-zod-client": "^1.18.1",
     "prettier": "catalog:",
-    "ts-jest": "^29.0.5",
     "yargs": "^17.4.1"
   },
   "dependencies": {

+ 3 - 5
apps/price_pusher/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 1
apps/price_pusher/package.json

@@ -46,6 +46,7 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/express": "^4.17.21",
     "@types/jest": "^27.4.1",
@@ -56,7 +57,6 @@
     "jest": "^29.7.0",
     "pino-pretty": "^11.2.1",
     "prettier": "catalog:",
-    "ts-jest": "^29.1.1",
     "ts-node": "catalog:"
   },
   "dependencies": {

+ 4 - 5
governance/xc_admin/packages/xc_admin_common/jest.config.js

@@ -1,8 +1,7 @@
-/** @type {import('ts-jest').JestConfigWithTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig({
   moduleNameMapper: {
     "^uuid$": "uuid",
   },
-};
+});

+ 2 - 2
governance/xc_admin/packages/xc_admin_common/package.json

@@ -47,12 +47,12 @@
   },
   "devDependencies": {
     "@types/bn.js": "^5.1.1",
+    "@pythnetwork/jest-config": "workspace:",
     "@types/jest": "^29.2.5",
     "@types/lodash": "^4.14.191",
     "fast-check": "^3.10.0",
     "jest": "^29.3.1",
-    "prettier": "catalog:",
-    "ts-jest": "^29.0.3"
+    "prettier": "catalog:"
   },
   "engines": {
     "node": ">=22.14.0",

+ 1 - 0
packages/jest-config/.prettierignore

@@ -0,0 +1 @@
+dist/

+ 1 - 0
packages/jest-config/eslint.config.js

@@ -0,0 +1 @@
+export { base as default } from "@cprussin/eslint-config";

+ 38 - 0
packages/jest-config/package.json

@@ -0,0 +1,38 @@
+{
+  "private": true,
+  "name": "@pythnetwork/jest-config",
+  "version": "0.0.0",
+  "type": "module",
+  "scripts": {
+    "build": "ts-duality",
+    "clean": "rm -rf dist/"
+  },
+  "devDependencies": {
+    "@better-builds/ts-duality": "catalog:",
+    "@cprussin/eslint-config": "catalog:",
+    "@cprussin/tsconfig": "catalog:",
+    "@types/jest": "^29"
+  },
+  "dependencies": {
+    "@swc/core": "^1.15.0",
+    "@swc/jest": "^0.2.39",
+    "jest-ts-webcompat-resolver": "^1.0.1",
+    "jest": "^29"
+  },
+  "exports": {
+    ".": {
+      "require": {
+        "types": "./dist/cjs/index.d.ts",
+        "default": "./dist/cjs/index.cjs"
+      },
+      "import": {
+        "types": "./dist/esm/index.d.ts",
+        "default": "./dist/esm/index.mjs"
+      }
+    },
+    "./package.json": "./package.json"
+  },
+  "module": "./dist/esm/index.mjs",
+  "types": "./dist/cjs/index.d.ts",
+  "main": "./dist/cjs/index.cjs"
+}

+ 13 - 0
packages/jest-config/src/index.ts

@@ -0,0 +1,13 @@
+import type { Config } from "jest";
+
+export function defineJestConfig(config?: Config) {
+  return {
+    ...config,
+    resolver: config?.resolver ?? "jest-ts-webcompat-resolver",
+    transform: {
+      "^.+\\.(t|j)sx?$": ["@swc/jest"],
+      ...config?.transform,
+    },
+    testEnvironment: config?.testEnvironment ?? "node",
+  } as unknown as Config;
+}

+ 8 - 0
packages/jest-config/tsconfig.json

@@ -0,0 +1,8 @@
+{
+  "extends": "@cprussin/tsconfig/base.json",
+  "compilerOptions": {
+    "incremental": false,
+    "noEmit": false,
+    "isolatedModules": false
+  }
+}

Plik diff jest za duży
+ 172 - 135
pnpm-lock.yaml


+ 3 - 5
price_service/client/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 3 - 5
price_service/sdk/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 2 - 2
price_service/sdk/js/package.json

@@ -35,13 +35,13 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@types/bn.js": "^5.1.5",
     "@types/jest": "^29.4.0",
     "eslint": "catalog:",
     "jest": "^29.4.0",
     "prettier": "catalog:",
-    "quicktype": "^23.0.76",
-    "ts-jest": "^29.0.5"
+    "quicktype": "^23.0.76"
   },
   "dependencies": {
     "bn.js": "^5.2.1"

+ 3 - 5
target_chains/aptos/sdk/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 1
target_chains/aptos/sdk/js/package.json

@@ -39,6 +39,7 @@
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
     "@truffle/hdwallet-provider": "^2.1.5",
+    "@pythnetwork/jest-config": "workspace:",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/jest": "^29.4.0",
     "@types/node": "^18.11.18",
@@ -49,7 +50,6 @@
     "eslint": "catalog:",
     "jest": "^29.4.1",
     "prettier": "catalog:",
-    "ts-jest": "^29.0.5",
     "web3": "^1.8.2",
     "yargs": "^17.4.1"
   },

+ 3 - 5
target_chains/ethereum/sdk/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 0
target_chains/ethereum/sdk/js/package.json

@@ -38,6 +38,7 @@
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
     "@pythnetwork/pyth-sdk-solidity": "workspace:*",
+    "@pythnetwork/jest-config": "workspace:",
     "@truffle/hdwallet-provider": "^2.1.5",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/jest": "^29.4.0",

+ 4 - 5
target_chains/solana/sdk/js/solana_utils/jest.config.js

@@ -1,8 +1,7 @@
-/** @type {import('ts-jest').JestConfigWithTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig({
   moduleNameMapper: {
     "^uuid$": "uuid",
   },
-};
+});

+ 1 - 0
target_chains/solana/sdk/js/solana_utils/package.json

@@ -35,6 +35,7 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@solana/wallet-adapter-react": "^0.15.28",
     "@types/jest": "^29.4.0",
     "@types/node": "^22.5.1",

+ 3 - 5
target_chains/sui/sdk/js-iota/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 1
target_chains/sui/sdk/js-iota/package.json

@@ -39,6 +39,7 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@truffle/hdwallet-provider": "^2.1.5",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/jest": "^29.4.0",
@@ -48,7 +49,6 @@
     "eslint": "catalog:",
     "jest": "^29.4.1",
     "prettier": "catalog:",
-    "ts-jest": "^29.0.5",
     "web3": "^1.8.2",
     "yargs": "^17.0.20"
   },

+ 3 - 5
target_chains/sui/sdk/js/jest.config.js

@@ -1,5 +1,3 @@
-/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
-module.exports = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-};
+import { defineJestConfig } from "@pythnetwork/jest-config";
+
+export default defineJestConfig();

+ 1 - 1
target_chains/sui/sdk/js/package.json

@@ -40,6 +40,7 @@
   "license": "Apache-2.0",
   "devDependencies": {
     "@cprussin/eslint-config": "catalog:",
+    "@pythnetwork/jest-config": "workspace:",
     "@truffle/hdwallet-provider": "^2.1.5",
     "@types/ethereum-protocol": "^1.0.2",
     "@types/jest": "^29.4.0",
@@ -51,7 +52,6 @@
     "eslint": "catalog:",
     "jest": "^29.4.1",
     "prettier": "catalog:",
-    "ts-jest": "^29.0.5",
     "web3": "^1.8.2",
     "yargs": "^17.0.20"
   },

+ 4 - 8
target_chains/ton/contracts/jest.config.ts → target_chains/ton/contracts/jest.config.js

@@ -1,10 +1,6 @@
-import type { Config } from "jest";
+const { defineJestConfig } = require("@pythnetwork/jest-config");
 
-const config: Config = {
-  preset: "ts-jest",
-  testEnvironment: "node",
-  testPathIgnorePatterns: ["/node_modules/", "/dist/"],
+module.exports = defineJestConfig({
   maxWorkers: 1, // Prevents serialization issues with BigInt during error reporting
-};
-
-export default config;
+  testPathIgnorePatterns: ["/node_modules/", "/dist/"],
+});

+ 1 - 0
target_chains/ton/contracts/package.json

@@ -11,6 +11,7 @@
   },
   "devDependencies": {
     "@pythnetwork/hermes-client": "workspace:*",
+    "@pythnetwork/jest-config": "workspace:",
     "@pythnetwork/price-service-sdk": "workspace:*",
     "@pythnetwork/pyth-ton-js": "workspace:*",
     "@pythnetwork/xc-admin-common": "workspace:*",

+ 1 - 1
target_chains/ton/contracts/tests/PythTest.spec.ts

@@ -853,7 +853,7 @@ describe("PythTest", () => {
 
     // Check initial value (should be empty)
     let result = await pythTest.getGovernanceDataSource();
-    expect(result).toEqual(null);
+    expect(result).toBeFalsy();
 
     // Deploy contract with initial governance data source
     await deployContract(

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików