Skip to content

Commit

Permalink
test(examples): use preset util functions in all example projects
Browse files Browse the repository at this point in the history
  • Loading branch information
ahnpnl committed Jul 10, 2024
1 parent 26e31a7 commit 7201375
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 256 deletions.
19 changes: 6 additions & 13 deletions examples/js-with-babel/jest-esm-isolated.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import preset from 'ts-jest/presets/index.js'
import { createJsWithBabelEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.jsWithBabelESM,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
babelConfig: true,
isolatedModules: true,
tsconfig: 'tsconfig-esm.json',
useESM: true,
},
],
},
...createJsWithBabelEsmPreset({
babelConfig: true,
tsconfig: 'tsconfig-esm.json',
isolatedModules: true,
})
}
17 changes: 5 additions & 12 deletions examples/js-with-babel/jest-esm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import preset from 'ts-jest/presets/index.js'
import { createJsWithBabelEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.jsWithBabelESM,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
babelConfig: true,
tsconfig: 'tsconfig-esm.json',
useESM: true,
},
],
},
...createJsWithBabelEsmPreset({
babelConfig: true,
tsconfig: 'tsconfig-esm.json'
})
}
16 changes: 5 additions & 11 deletions examples/js-with-babel/jest-isolated.config.cjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
const preset = require('ts-jest/presets')
const { createJsWithBabelPreset } = require('ts-jest')

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.jsWithBabel,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
babelConfig: true,
isolatedModules: true,
},
],
},
...createJsWithBabelPreset({
babelConfig: true,
isolatedModules: true,
})
}
13 changes: 5 additions & 8 deletions examples/js-with-babel/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const { createJsWithBabelPreset } = require('ts-jest')

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
babelConfig: true,
},
],
},
...createJsWithBabelPreset({
babelConfig: true,
})
}
17 changes: 5 additions & 12 deletions examples/js-with-ts/jest-esm-isolated.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import preset from 'ts-jest/presets/index.js'
import { createJsWithTsPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.jsWithTsESM,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: 'tsconfig-esm.json',
useESM: true,
},
],
},
...createJsWithTsPreset({
tsconfig: 'tsconfig-esm.json',
isolatedModules: true,
})
}
15 changes: 4 additions & 11 deletions examples/js-with-ts/jest-esm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import preset from 'ts-jest/presets/index.js'
import { createJsWithTsPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.jsWithTsESM,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
tsconfig: 'tsconfig-esm.json',
useESM: true,
},
],
},
...createJsWithTsPreset({
tsconfig: 'tsconfig-esm.json'
})
}
14 changes: 4 additions & 10 deletions examples/js-with-ts/jest-isolated.config.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const preset = require('ts-jest/presets')
const { createJsWithTsPreset } = require('ts-jest')

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.jsWithTs,
transform: {
'^.+\.[tj]sx?$': [
'ts-jest',
{
isolatedModules: true,
},
],
},
...createJsWithTsPreset({
isolatedModules: true,
})
}
4 changes: 2 additions & 2 deletions examples/js-with-ts/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const preset = require('ts-jest/presets')
const { createJsWithTsPreset } = require('ts-jest')

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.jsWithTs,
...createJsWithTsPreset()
}
17 changes: 5 additions & 12 deletions examples/monorepo-app/tests/project-1/jest-esm-isolated.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import preset from 'ts-jest/presets/index.js'
import { createDefaultEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.defaultsESM,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: 'tests/project-1/tsconfig-esm.json',
useESM: true,
},
],
},
...createDefaultEsmPreset({
tsconfig: 'tests/project-1/tsconfig-esm.json',
isolatedModules: true,
})
}
15 changes: 4 additions & 11 deletions examples/monorepo-app/tests/project-1/jest-esm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import preset from 'ts-jest/presets/index.js'
import { createDefaultEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.defaultsESM,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tests/project-1/tsconfig-esm.json',
useESM: true,
},
],
},
...createDefaultEsmPreset({
tsconfig: 'tests/project-1/tsconfig-esm.json',
})
}
14 changes: 4 additions & 10 deletions examples/monorepo-app/tests/project-1/jest-isolated.config.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const preset = require('ts-jest/presets');
const { createDefaultPreset } = require('ts-jest');

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.defaults,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
},
],
},
...createDefaultPreset({
isolatedModules: true,
})
}
4 changes: 2 additions & 2 deletions examples/monorepo-app/tests/project-1/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const preset = require('ts-jest/presets');
const { createDefaultPreset } = require('ts-jest');

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.defaults,
...createDefaultPreset()
}
17 changes: 5 additions & 12 deletions examples/monorepo-app/tests/project-2/jest-esm-isolated.config.mjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import preset from 'ts-jest/presets/index.js'
import { createDefaultEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.defaultsESM,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: 'tests/project-2/tsconfig-esm.json',
useESM: true,
},
],
},
...createDefaultEsmPreset({
tsconfig: 'tests/project-2/tsconfig-esm.json',
isolatedModules: true,
})
}
15 changes: 4 additions & 11 deletions examples/monorepo-app/tests/project-2/jest-esm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import preset from 'ts-jest/presets/index.js'
import { createDefaultEsmPreset } from 'ts-jest'

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...preset.defaultsESM,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
tsconfig: 'tests/project-2/tsconfig-esm.json',
useESM: true,
},
],
},
...createDefaultEsmPreset({
tsconfig: 'tests/project-2/tsconfig-esm.json',
})
}
14 changes: 4 additions & 10 deletions examples/monorepo-app/tests/project-2/jest-isolated.config.cjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
const preset = require('ts-jest/presets');
const { createDefaultPreset } = require('ts-jest');

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.defaults,
transform: {
'^.+\\.tsx?$': [
'ts-jest',
{
isolatedModules: true,
},
],
},
...createDefaultPreset({
isolatedModules: true,
})
}
4 changes: 2 additions & 2 deletions examples/monorepo-app/tests/project-2/jest.config.cjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const preset = require('ts-jest/presets');
const { createDefaultPreset } = require('ts-jest');

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...preset.defaults,
...createDefaultPreset()
}
23 changes: 12 additions & 11 deletions examples/react-app/jest-esm-isolated.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import baseEsmCfg from './jest-esm.config.mjs'
import { createDefaultEsmPreset } from 'ts-jest'

const defaultPreset = createDefaultEsmPreset({
tsconfig: 'tsconfig-esm.spec.json',
isolatedModules: true,
})

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...baseEsmCfg,
...defaultPreset,
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
testEnvironment: 'jsdom',
transform: {
...baseEsmCfg.transform,
'^.+\\.(ts|tsx|js|jsx|mjs|cjs)$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: 'tsconfig-esm.spec.json',
useESM: true,
},
],
...defaultPreset.transform,
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
},
}
22 changes: 11 additions & 11 deletions examples/react-app/jest-esm.config.mjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import baseCfg from './jest.config.cjs'
import { createDefaultEsmPreset } from 'ts-jest'

const defaultPreset = createDefaultEsmPreset({
tsconfig: 'tsconfig-esm.spec.json',
})

/** @type {import('ts-jest').JestConfigWithTsJest} */
export default {
...baseCfg,
preset: 'ts-jest/presets/js-with-babel-esm',
...defaultPreset,
setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
testEnvironment: 'jsdom',
transform: {
...baseCfg.transform,
'^.+\\.(ts|tsx|js|jsx|mjs|cjs)$': [
'ts-jest',
{
tsconfig: 'tsconfig-esm.spec.json',
useESM: true,
},
],
...defaultPreset.transform,
'^.+\\.css$': '<rootDir>/config/jest/cssTransform.js',
'^(?!.*\\.(js|jsx|mjs|cjs|ts|tsx|css|json)$)': '<rootDir>/config/jest/fileTransform.js',
},
}
14 changes: 7 additions & 7 deletions examples/react-app/jest-isolated.config.cjs
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
const baseCfg = require('./jest.config.cjs')
const { createDefaultPreset } = require('ts-jest')

const defaultPreset = createDefaultPreset({
tsconfig: 'tsconfig.spec.json',
isolatedModules: true,
})

/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
...baseCfg,
transform: {
...baseCfg.transform,
'^.+\\.(ts|tsx|js|jsx|mjs|cjs)$': [
'ts-jest',
{
isolatedModules: true,
tsconfig: 'tsconfig.spec.json',
},
],
...defaultPreset.transform,
},
}
Loading

0 comments on commit 7201375

Please sign in to comment.