build: replace babel-jest with ts-jest

This commit is contained in:
Tom French 2022-05-07 13:33:17 +01:00
parent e3ee0c61a6
commit 9be15eaee1
16 changed files with 1085 additions and 1190 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,7 +25,7 @@
"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": "yarn workspaces foreach --parallel --verbose run test",
"test:debug": "node ./node_modules/.bin/jest --runInBand --useStderr",
"test:debug-brk": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
"rebuild-electron": "./node_modules/.bin/electron-rebuild -f -m ./packages/loot-core",
@ -34,7 +34,6 @@
"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

@ -3,14 +3,11 @@ const isReactNative = process.env.REACT_APP_IS_REACT_NATIVE;
module.exports = {
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'
},
globals: {
__TESTING__: true
}

View file

@ -1,5 +1,5 @@
module.exports = {
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'json'],
moduleFileExtensions: ['testing.js', 'web.js', 'mjs', 'js', 'ts', 'json'],
testEnvironment: 'jsdom',
testPathIgnorePatterns: ['/node_modules/', '/lib/'].filter(Boolean),
testMatch: ['**/*.web.test.js'],
@ -7,9 +7,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

@ -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

@ -11,9 +11,6 @@
"test": "jest",
"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'
}
};

2173
yarn.lock

File diff suppressed because it is too large Load diff