Merge pull request #203 from TomAFrench/ts-jest

Replace babel-jest with ts-jest
This commit is contained in:
Tom French 2022-08-24 21:31:21 +01:00 committed by GitHub
commit 01be80d562
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 1097 additions and 1200 deletions

View file

@ -1,24 +0,0 @@
const { join, resolve } = require('path');
const { createTransformer } = require('babel-jest');
const packagePath = resolve('./');
const packageGlob = join(packagePath, 'packages/*');
module.exports = createTransformer({
babelrcRoots: packageGlob,
// TODO: This is awful and a mess and we should fix it.
//
// Forcing this on allows certain packages in node_modules to be
// exported as ESM, which jest usually errors on. node_modules are
// usually not transformed, but you can allowlist one in the
// `jest.config.js` for your project like this:
//
// transformIgnorePatterns: [
// '/node_modules/(?!absurd-sql)'
// ],
//
// Without this explicit plugin, even though Jest transforms the
// module it won't recognize ESM
plugins: ['@babel/plugin-transform-modules-commonjs']
});

View file

@ -1,9 +0,0 @@
const { join, resolve } = require('path');
const { createTransformer } = require('babel-jest');
const packagePath = resolve('./');
const packageGlob = join(packagePath, 'packages/*');
module.exports = createTransformer({
babelrcRoots: packageGlob
});

View file

@ -1,8 +0,0 @@
module.exports = {
projects: [
'<rootDir>/packages/loot-core',
'<rootDir>/packages/loot-core/jest.web.config.js',
'<rootDir>/packages/loot-design',
'<rootDir>/packages/loot-design/jest.rn.config.js'
]
};

View file

@ -25,16 +25,14 @@
"start:browser": "npm-run-all --parallel 'start:browser-*'",
"start:browser-backend": "yarn workspace loot-core watch:browser",
"start:browser-frontend": "yarn workspace @actual-app/web start:browser",
"test": "./node_modules/.bin/jest --maxWorkers=4",
"test:debug": "node ./node_modules/.bin/jest --runInBand --useStderr",
"test:debug-brk": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
"test": "yarn workspaces foreach --parallel --verbose run test",
"test:debug": "yarn workspaces foreach --verbose run test",
"rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/loot-core",
"rebuild-node": "yarn workspace loot-core rebuild",
"lint": "yarn workspace loot-core lint",
"postinstall": "rm -rf ./packages/loot-design/node_modules/react && rm -rf ./packages/mobile/node_modules/react && rm -rf ./node_modules/react-native && patch-package"
},
"devDependencies": {
"@babel/plugin-transform-modules-commonjs": "^7.18.2",
"cross-env": "^5.1.5",
"husky": "^3.0.4",
"npm-run-all": "^4.1.3",

View file

@ -1,16 +1,14 @@
const isReactNative = process.env.REACT_APP_IS_REACT_NATIVE;
module.exports = {
preset: 'ts-jest/presets/js-with-ts-esm',
moduleFileExtensions: ['testing.js', 'electron.js']
.concat(isReactNative ? ['ios.js', 'mobile.js'] : [])
.concat(['mjs', 'js', 'json']),
.concat(['mjs', 'js', 'ts', 'json']),
setupFilesAfterEnv: ['<rootDir>/src/mocks/setup.js'],
testEnvironment: 'node',
testPathIgnorePatterns: ['/node_modules/', '/lib/', 'index.web.test.js'],
transformIgnorePatterns: ['__mocks__'],
transform: {
'^.+\\.(js|ts|tsx)?$': '<rootDir>/../../jest-babel-transformer'
},
testPathIgnorePatterns: ['/node_modules/', '/lib/', '.+/index.web.test.js'],
transformIgnorePatterns: ['/node_modules/', '__mocks__'],
globals: {
__TESTING__: true
}

View file

@ -1,5 +1,6 @@
module.exports = {
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'json'],
preset: 'ts-jest/presets/js-with-ts-esm',
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'ts', 'json'],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/lib/'].filter(Boolean),
testMatch: ['**/*.web.test.js'],
@ -7,9 +8,6 @@ module.exports = {
'__mocks__',
'/node_modules/(?!perf-deets|absurd-sql)'
],
transform: {
'^.+\\.(js|ts|tsx)?$': '<rootDir>/../../jest-babel-transformer-esm'
},
globals: {
__TESTING__: true
}

View file

@ -9,7 +9,10 @@
"build:api": "cross-env NODE_ENV=development webpack --config ./webpack/webpack.api.config.js",
"build:browser": "cross-env NODE_ENV=production ./bin/build-browser",
"watch:browser": "cross-env NODE_ENV=development ./bin/build-browser",
"lint": "eslint src"
"lint": "eslint src",
"test": "npm-run-all -cp 'test:*'",
"test:node": "jest -c jest.config.js",
"test:web": "jest -c jest.web.config.js"
},
"author": "",
"license": "ISC",
@ -39,8 +42,8 @@
"@actual-app/api": "*",
"@actual-app/import-ynab4": "*",
"@babel/core": "~7.14.3",
"@types/jest": "^27.5.0",
"adm-zip": "cthackers/adm-zip#ff17ae85",
"babel-jest": "25.2.6",
"babel-loader": "^8.0.6",
"buffer": "^5.5.0",
"cross-env": "^7.0.3",
@ -52,7 +55,7 @@
"fake-indexeddb": "^3.1.3",
"fast-check": "2.13.0",
"fast-glob": "^2.2.0",
"jest": "25.2.7",
"jest": "^28.1.0",
"jsverify": "^0.8.4",
"lru-cache": "^5.1.1",
"memfs": "3.1.1",
@ -60,6 +63,7 @@
"mock-require": "^3.0.2",
"mockdate": "^3.0.5",
"murmurhash": "^0.0.2",
"npm-run-all": "^4.1.3",
"perf-deets": "^1.0.15",
"prettier": "^1.19.1",
"sanitize-filename": "^1.6.1",
@ -67,6 +71,9 @@
"snapshot-diff": "^0.2.2",
"source-map": "^0.7.3",
"throttleit": "^1.0.0",
"ts-jest": "^28.0.1",
"ts-node": "^10.7.0",
"typescript": "^4.6.4",
"uuid": "3.3.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.9",

View file

@ -25,6 +25,10 @@ import { rebuildMerkleHash } from './repair';
const { PostError, SyncError } = require('../errors');
const connection = require('../../platform/server/connection');
export { default as makeTestMessage } from './make-test-message';
export { default as resetSync } from './reset';
export { default as repairSync } from './repair';
let FULL_SYNC_DELAY = 1000;
let SYNCING_MODE = 'enabled';
@ -64,10 +68,6 @@ export function checkSyncingMode(mode) {
}
}
export makeTestMessage from './make-test-message';
export resetSync from './reset';
export repairSync from './repair';
function apply(msg, prev) {
let { dataset, row, column, value } = msg;

View file

@ -1,3 +0,0 @@
{
"presets": ["jwl-app", "@babel/react"]
}

View file

@ -0,0 +1,3 @@
{
"presets": ["jwl-app", "@babel/preset-react"]
}

View file

@ -1,10 +1,7 @@
module.exports = {
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'json'],
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'ts', 'json'],
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/setupTests.js'],
transform: {
'.*': '<rootDir>/../../jest-babel-transformer'
},
testPathIgnorePatterns: [
'/node_modules/',
'/lib/',

View file

@ -5,14 +5,12 @@ module.exports = {
'mobile.js',
'mjs',
'js',
'ts',
'json'
],
moduleDirectories: ['<rootDir>/node_modules', 'node_modules'],
testEnvironment: 'jsdom',
setupFilesAfterEnv: ['<rootDir>/src/setupTests.js'],
transform: {
'^.+\\.(js|ts|tsx)?$': '<rootDir>/../../jest-babel-transformer',
},
testMatch: ['<rootDir>/src/components/mobile/**/*.test.js'],
testPathIgnorePatterns: [
'/node_modules/(?!loot-core).+\\.js$'

View file

@ -15,9 +15,12 @@
"fast-glob": "^2.2.2",
"formik": "^0.11.10",
"glamor": "^2.20.40",
"jest": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"memoize-one": "^4.0.0",
"memoizee": "^0.4.12",
"node-noop": "1.0.0",
"npm-run-all": "^4.1.3",
"polished": "^1.8.1",
"prettier": "^1.14.2",
"prop-types": "15.6.0",
@ -45,7 +48,10 @@
"scripts": {
"start": "react-scripts start",
"start:mobile": "IS_REACT_NATIVE=1 react-scripts start",
"postinstall": "patch-package"
"postinstall": "patch-package",
"test": "npm-run-all -cp 'test:*'",
"test:web": "jest -c jest.config.js",
"test:react-native": "jest -c jest.rn.config.js"
},
"homepage": "./",
"manifest": "manifest.json",

View file

@ -0,0 +1,3 @@
module.exports = {
preset: "react-native"
};

View file

@ -8,12 +8,9 @@
"android": "npx react-native run-android --appId com.shiftreset.actual",
"android:prod": "rm -f ./android/app/build/generated/assets/react/release/index.android.bundle && npx react-native run-android --appId com.shiftreset.actual --variant=release",
"ios": "react-native run-ios",
"test": "jest",
"test": "jest --passWithNoTests",
"postinstall": "patch-package"
},
"jest": {
"preset": "react-native"
},
"dependencies": {
"@babel/core": "~7.12.9",
"@babel/runtime": "~7.12.18",
@ -25,6 +22,7 @@
"@react-navigation/native-stack": "^6.1.0",
"@reactions/component": "^2.0.2",
"@sentry/react-native": "3.0.2",
"jest": "^28.1.0",
"jsc-android": "^241213.1.0",
"loot-core": "*",
"memoize-one": "^4.0.0",

View file

@ -1,9 +1,6 @@
module.exports = {
moduleFileExtensions: ['js', 'json', 'testing.js'],
moduleFileExtensions: ['js', 'ts', 'json', 'testing.js'],
setupTestFrameworkScriptFile: './test/setup.js',
testEnvironment: 'node',
rootDir: '../',
transform: {
'^.+\\.js?$': 'babel-jest'
}
};

View file

@ -3,13 +3,14 @@
"target": "ES2022",
"lib": ["ES2021", "DOM"],
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"experimentalDecorators": true,
"resolveJsonModule": true,
"downlevelIteration": true,
"jsx": "preserve",
// Check JS files too
"allowJs": true,
"checkJs": true,
"checkJs": false,
// Used for temp builds
"outDir": "build",
"moduleResolution": "Node",

2173
yarn.lock

File diff suppressed because it is too large Load diff