Skip to content

Commit

Permalink
chore: ts-jest config
Browse files Browse the repository at this point in the history
  • Loading branch information
work-kevin-flynn committed Nov 19, 2024
1 parent 83dbde1 commit b39a379
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
17 changes: 11 additions & 6 deletions packages/react/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
*/

import type { Config } from 'jest';
import path from 'path';
import { pathsToModuleNameMapper } from 'ts-jest';
import { compilerOptions } from '../../tsconfig.base.json';

const config: Config = {
// All imported modules in your tests should be mocked automatically
Expand Down Expand Up @@ -76,9 +77,7 @@ const config: Config = {
moduleFileExtensions: ['js', 'jsx', 'ts', 'tsx'],

// A map from regular expressions to module names or to arrays of module names that allow to stub out resources with a single module
moduleNameMapper: {
'@aelf-web-login/wallet-adapter-(.*)$': path.join(__dirname, '../$1'),
},
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],
Expand Down Expand Up @@ -120,7 +119,7 @@ const config: Config = {
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
rootDir: './',
// rootDir: './',

// A list of paths to directories that Jest should use to search for files in
// roots: [
Expand Down Expand Up @@ -170,7 +169,7 @@ const config: Config = {

// A map from regular expressions to paths to transformers
transform: {
'^.+\\.(js|jsx|ts|tsx)$': 'babel-jest',
'^.+\\.(js|jsx|ts|tsx)$': ['ts-jest', { diagnostics: false }],
},
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
Expand All @@ -189,6 +188,12 @@ const config: Config = {

// Whether to use watchman for file crawling
// watchman: true,
preset: 'ts-jest',
rootDir: './',
roots: ['<rootDir>'],
modulePaths: ['./', compilerOptions.baseUrl],
moduleDirectories: ['node_modules', 'src'],
moduleNameMapper: pathsToModuleNameMapper(compilerOptions.paths, { prefix: './../../' }),
};

export default config;
4 changes: 3 additions & 1 deletion packages/react/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
import '@testing-library/jest-dom';
global.fetch = require('node-fetch');
import 'node-fetch';

jest.mock('node-fetch', () => jest.fn());
15 changes: 8 additions & 7 deletions tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,22 @@
"strict": true,
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"allowJs": false,
"allowJs": true,
"isolatedModules": false,
"declaration": true,
"skipLibCheck": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"paths": {
"@aelf-web-login/utils": ["./packages/utils/src/index.ts"],
"@aelf-web-login/wallet-adapter-base": ["./packages/base/src/index.ts"],
"@aelf-web-login/wallet-adapter-bridge": ["./packages/bridge/src/index.ts"],
"@aelf-web-login/utils": ["./packages/utils/src"],
"@aelf-web-login/wallet-adapter-base": ["./packages/base/src"],
"@aelf-web-login/wallet-adapter-bridge": ["./packages/bridge/src"],
"@aelf-web-login/wallet-adapter-react": ["./packages/react/src/index.tsx"],
"@aelf-web-login/wallet-adapter-portkey-aa": ["./packages/wallets/portkey-aa/src/index.ts"],
"@aelf-web-login/wallet-adapter-portkey-aa": ["./packages/wallets/portkey-aa/src"],
"@aelf-web-login/wallet-adapter-portkey-discover": [
"./packages/wallets/portkey-discover/src/index.ts"
"./packages/wallets/portkey-discover/src"
],
"@aelf-web-login/wallet-adapter-night-elf": ["./packages/wallets/night-elf/src/index.ts"]
"@aelf-web-login/wallet-adapter-night-elf": ["./packages/wallets/night-elf/src"]
}
}
}

0 comments on commit b39a379

Please sign in to comment.