Page Not Found
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
diff --git a/404.html b/404.html index a82248ef9c..9aed5108ac 100644 --- a/404.html +++ b/404.html @@ -12,8 +12,8 @@ - - + +
We could not find what you were looking for.
Please contact the owner of the site that linked you to the original URL and let them know their link is broken.
namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function d(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"tsconfig"})," option allows you to define which ",(0,o.jsx)(n.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,o.jsx)(n.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,o.jsxs)(n.p,{children:["By default ",(0,o.jsx)(n.code,{children:"ts-jest"})," will try to find a ",(0,o.jsx)(n.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,o.jsx)(n.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,o.jsx)(n.code,{children:"ES2015"})," is used as ",(0,o.jsx)(n.code,{children:"target"})," instead of ",(0,o.jsx)(n.code,{children:"ES5"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["If you need to use defaults and force ",(0,o.jsx)(n.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,o.jsx)(n.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,o.jsx)(n.code,{children:"false"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,o.jsxs)(n.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,o.jsx)(n.code,{children:"tsconfig"})," file"]}),"\n",(0,o.jsxs)(n.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,o.jsx)(n.code,{children:"tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function d(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,s.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(n.p,{children:["The ",(0,o.jsx)(n.code,{children:"tsconfig"})," option allows you to define which ",(0,o.jsx)(n.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,o.jsx)(n.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,o.jsxs)(n.p,{children:["By default ",(0,o.jsx)(n.code,{children:"ts-jest"})," will try to find a ",(0,o.jsx)(n.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,o.jsx)(n.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,o.jsx)(n.code,{children:"ES2015"})," is used as ",(0,o.jsx)(n.code,{children:"target"})," instead of ",(0,o.jsx)(n.code,{children:"ES5"}),"."]}),"\n",(0,o.jsxs)(n.p,{children:["If you need to use defaults and force ",(0,o.jsx)(n.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,o.jsx)(n.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,o.jsx)(n.code,{children:"false"}),"."]}),"\n",(0,o.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,o.jsxs)(n.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,o.jsx)(n.code,{children:"tsconfig"})," file"]}),"\n",(0,o.jsxs)(n.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,o.jsx)(n.code,{children:"mocked<T>(item: T, deep = false)
",id:"mockedtitem-t-deep--false",level:2},{value:"Example",id:"example",level:3}];function a(e){const t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.admonition,{type:"warning",children:(0,s.jsxs)(t.p,{children:["This function is now deprecated and will be removed in ",(0,s.jsx)(t.strong,{children:"28.0.0"}),". The function has been integrated into ",(0,s.jsx)(t.code,{children:"jest-mock"})," package\nas a part of Jest ",(0,s.jsx)(t.strong,{children:"27.4.0"}),", see ",(0,s.jsx)(t.a,{href:"https://github.com/facebook/jest/pull/12089",children:"https://github.com/facebook/jest/pull/12089"}),". Please use the one from ",(0,s.jsx)(t.code,{children:"jest-mock"})," instead."]})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"ts-jest"})," provides some test utilities to be used in your test, related to TypeScript."]}),"\n",(0,s.jsx)(t.h2,{id:"mockedtitem-t-deep--false",children:(0,s.jsx)(t.code,{children:"mockedmocked<T>(item: T, deep = false)
",id:"mockedtitem-t-deep--false",level:2},{value:"Example",id:"example",level:3}];function a(e){const t={a:"a",admonition:"admonition",code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.admonition,{type:"warning",children:(0,s.jsxs)(t.p,{children:["This function is now deprecated and will be removed in ",(0,s.jsx)(t.strong,{children:"28.0.0"}),". The function has been integrated into ",(0,s.jsx)(t.code,{children:"jest-mock"})," package\nas a part of Jest ",(0,s.jsx)(t.strong,{children:"27.4.0"}),", see ",(0,s.jsx)(t.a,{href:"https://github.com/facebook/jest/pull/12089",children:"https://github.com/facebook/jest/pull/12089"}),". Please use the one from ",(0,s.jsx)(t.code,{children:"jest-mock"})," instead."]})}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.code,{children:"ts-jest"})," provides some test utilities to be used in your test, related to TypeScript."]}),"\n",(0,s.jsx)(t.h2,{id:"mockedtitem-t-deep--false",children:(0,s.jsx)(t.code,{children:"mockedts-jest
process",id:"ts-jest-process",level:2}];function d(e){const t={code:"code",em:"em",h2:"h2",img:"img",p:"p",...(0,o.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.p,{children:(0,n.jsxs)(t.em,{children:["These are internal technical documents. If you're not a contributor to ",(0,n.jsx)(t.code,{children:"ts-jest"}),", but simply trying to use the library you'll find nothing of value here"]})}),"\n",(0,n.jsx)(t.h2,{id:"jest-process",children:"Jest process"}),"\n",(0,n.jsx)(t.img,{src:"https://www.plantuml.com/plantuml/png/NP0n5e8m44Jxd68xaq8E08M5fQU8C97uS8FPJS7jVI0FmNRspyo-4VLPZQaptYLcs5E80qwkCIO6ihqNygJPiuIKNnT7seF9JX2t0Di9cMRu0RtwjiSDqn6kTsIresnLLQun60HaEJbJ5m4z8Kht4WSzHsuCk8lX-r5aQcVhN_fiMdHg4ojO3v7xxZ6d5Y9hRrt6pklgtOf-rbNOvfc70NSV"}),"\n",(0,n.jsxs)(t.h2,{id:"ts-jest-process",children:[(0,n.jsx)(t.code,{children:"ts-jest"})," process"]}),"\n",(0,n.jsx)(t.img,{src:"https://www.plantuml.com/plantuml/png/ZLJRRjim37tNLn3Omn9WwGUaG8Uz3YWmOFq1nQ9YjJ8PY7Iz0lduGHV7YHjWyvDruI7FuH7FfyGTYd0w6r6Rr9YzoayKVMWd6-4nTRXzD2Pus4ZFOtGWcW8TW__ulWNjaM3pWR8r-rTXMWuVpUu9nfEpYgR2F1g3KH0sn5k3v8Ali3v493iW83c1AMWF3-v1vHPz2YU46OXO4L8uzcg8WH0TA4F7mob4D0vzeA212JAsv6IGGwuBCESlBtqGZNXkSGasdUrwTDjpgIi8HwleO60tHfHRkWlIlaje5S6IWm9WL21QEe9WUW-vtiPsztHXK3CGd31944NI6hlIj0e80muDsYSUFWNTAFllqlUDSD7QQB8aUVbSxZPn8terHJsOGenmm5bUPwp0Ei6Ln000IpLGljkCTUyYJbqkMQ5zWtr360M1VQv-3hYSLzaTs0E_Nwdlp88momP1CfA3gKUw72UqBj2ncQJkhNZKlbKAeoWFyEFtIraNsJod0PDK3ci6FQQIU2e_FGVHd8rzEt_DBstWxYrVSapu3Qp0X362dSiP1TEk-3bRV4vfixVdAmURYJ51n-J3qNnciNkwz6xnN-7amv-s0uCzDHwVJ7UxVSzyHQRprJov-_YN9zycIMxkmHumhlnPzkuFeaNapiOeDNoNfJINz8iP_tS4zLR0UiNqgs90p_osVZGsDsPzwTwOMseCrRdv8YJKCP4OuG6rpqu8-hMyB5EiQGK8fzQEwv5LozmlXhlg8fBx2m00"})]})}function a(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},8453:(e,t,s)=>{s.d(t,{R:()=>i,x:()=>c});var n=s(6540);const o={},r=n.createContext(o);function i(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),n.createElement(r.Provider,{value:t},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkts_jest_docs=self.webpackChunkts_jest_docs||[]).push([[8317],{8224:(e,t,s)=>{s.r(t),s.d(t,{assets:()=>l,contentTitle:()=>i,default:()=>a,frontMatter:()=>r,metadata:()=>c,toc:()=>u});var n=s(4848),o=s(8453);const r={id:"processing",title:"Processing flow"},i=void 0,c={id:"processing",title:"Processing flow",description:"These are internal technical documents. If you're not a contributor to ts-jest, but simply trying to use the library you'll find nothing of value here",source:"@site/versioned_docs/version-29.0/processing.md",sourceDirName:".",slug:"/processing",permalink:"/ts-jest/docs/29.0/processing",draft:!1,unlisted:!1,editUrl:"https://github.com/kulshekhar/ts-jest/edit/main/website/versioned_docs/version-29.0/processing.md",tags:[],version:"29.0",lastUpdatedBy:"renovate[bot]",lastUpdatedAt:1726768481e3,frontMatter:{id:"processing",title:"Processing flow"},sidebar:"version-29.0-docs",previous:{title:"Introduction",permalink:"/ts-jest/docs/29.0/"},next:{title:"Contributing",permalink:"/ts-jest/docs/29.0/contributing"}},l={},u=[{value:"Jest process",id:"jest-process",level:2},{value:"ts-jest
process",id:"ts-jest-process",level:2}];function d(e){const t={code:"code",em:"em",h2:"h2",img:"img",p:"p",...(0,o.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(t.p,{children:(0,n.jsxs)(t.em,{children:["These are internal technical documents. If you're not a contributor to ",(0,n.jsx)(t.code,{children:"ts-jest"}),", but simply trying to use the library you'll find nothing of value here"]})}),"\n",(0,n.jsx)(t.h2,{id:"jest-process",children:"Jest process"}),"\n",(0,n.jsx)(t.img,{src:"https://www.plantuml.com/plantuml/png/NP0n5e8m44Jxd68xaq8E08M5fQU8C97uS8FPJS7jVI0FmNRspyo-4VLPZQaptYLcs5E80qwkCIO6ihqNygJPiuIKNnT7seF9JX2t0Di9cMRu0RtwjiSDqn6kTsIresnLLQun60HaEJbJ5m4z8Kht4WSzHsuCk8lX-r5aQcVhN_fiMdHg4ojO3v7xxZ6d5Y9hRrt6pklgtOf-rbNOvfc70NSV"}),"\n",(0,n.jsxs)(t.h2,{id:"ts-jest-process",children:[(0,n.jsx)(t.code,{children:"ts-jest"})," process"]}),"\n",(0,n.jsx)(t.img,{src:"https://www.plantuml.com/plantuml/png/ZLJRRjim37tNLn3Omn9WwGUaG8Uz3YWmOFq1nQ9YjJ8PY7Iz0lduGHV7YHjWyvDruI7FuH7FfyGTYd0w6r6Rr9YzoayKVMWd6-4nTRXzD2Pus4ZFOtGWcW8TW__ulWNjaM3pWR8r-rTXMWuVpUu9nfEpYgR2F1g3KH0sn5k3v8Ali3v493iW83c1AMWF3-v1vHPz2YU46OXO4L8uzcg8WH0TA4F7mob4D0vzeA212JAsv6IGGwuBCESlBtqGZNXkSGasdUrwTDjpgIi8HwleO60tHfHRkWlIlaje5S6IWm9WL21QEe9WUW-vtiPsztHXK3CGd31944NI6hlIj0e80muDsYSUFWNTAFllqlUDSD7QQB8aUVbSxZPn8terHJsOGenmm5bUPwp0Ei6Ln000IpLGljkCTUyYJbqkMQ5zWtr360M1VQv-3hYSLzaTs0E_Nwdlp88momP1CfA3gKUw72UqBj2ncQJkhNZKlbKAeoWFyEFtIraNsJod0PDK3ci6FQQIU2e_FGVHd8rzEt_DBstWxYrVSapu3Qp0X362dSiP1TEk-3bRV4vfixVdAmURYJ51n-J3qNnciNkwz6xnN-7amv-s0uCzDHwVJ7UxVSzyHQRprJov-_YN9zycIMxkmHumhlnPzkuFeaNapiOeDNoNfJINz8iP_tS4zLR0UiNqgs90p_osVZGsDsPzwTwOMseCrRdv8YJKCP4OuG6rpqu8-hMyB5EiQGK8fzQEwv5LozmlXhlg8fBx2m00"})]})}function a(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,n.jsx)(t,{...e,children:(0,n.jsx)(d,{...e})}):d(e)}},8453:(e,t,s)=>{s.d(t,{R:()=>i,x:()=>c});var n=s(6540);const o={},r=n.createContext(o);function i(e){const t=n.useContext(r);return n.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function c(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:i(e.components),n.createElement(r.Provider,{value:t},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/265d7427.4156c41e.js b/assets/js/265d7427.0ea65ab8.js
similarity index 98%
rename from assets/js/265d7427.4156c41e.js
rename to assets/js/265d7427.0ea65ab8.js
index fe25c51d07..f73f6136d8 100644
--- a/assets/js/265d7427.4156c41e.js
+++ b/assets/js/265d7427.0ea65ab8.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkts_jest_docs=self.webpackChunkts_jest_docs||[]).push([[7556],{8307:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>d});var s=n(4848),o=n(8453);const i={title:"Stringify content option"},r=void 0,a={id:"getting-started/options/stringifyContentPathRegex",title:"Stringify content option",description:"The stringifyContentPathRegex option has been kept for backward compatibility of HTML_TRANSFORM",source:"@site/versioned_docs/version-27.0/getting-started/options/stringifyContentPathRegex.md",sourceDirName:"getting-started/options",slug:"/getting-started/options/stringifyContentPathRegex",permalink:"/ts-jest/docs/27.0/getting-started/options/stringifyContentPathRegex",draft:!1,unlisted:!1,editUrl:"https://github.com/kulshekhar/ts-jest/edit/main/website/versioned_docs/version-27.0/getting-started/options/stringifyContentPathRegex.md",tags:[],version:"27.0",lastUpdatedBy:"renovate[bot]",lastUpdatedAt:1726767874e3,frontMatter:{title:"Stringify content option"}},c={},d=[{value:"Example",id:"example",level:3}];function l(e){const t={code:"code",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," option has been kept for backward compatibility of ",(0,s.jsx)(t.code,{children:"__HTML_TRANSFORM__"}),"\nIt's a regular expression pattern used to match the path of file to be transformed.\nIf it matches, the file will be exported as a module exporting its content."]}),"\n",(0,s.jsxs)(t.p,{children:["Let's say for example that you have a file ",(0,s.jsx)(t.code,{children:"foo.ts"})," which contains ",(0,s.jsx)(t.code,{children:'export default "bar"'}),", and your ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," is set to ",(0,s.jsx)(t.code,{children:"foo\\\\.ts$"}),", the resulting module won't be the result of compiling ",(0,s.jsx)(t.code,{children:"foo.ts"})," source, but instead it'll be a module which exports the string ",(0,s.jsx)(t.code,{children:'"export default \\"bar\\""'}),"."]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"CAUTION"}),": Whatever file(s) you want to match with ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," pattern, you must ensure the Jest ",(0,s.jsx)(t.code,{children:"transform"})," option pointing to ",(0,s.jsx)(t.code,{children:"ts-jest"})," matches them. You may also have to add the extension(s) of this/those file(s) to ",(0,s.jsx)(t.code,{children:"moduleFileExtensions"})," Jest option."]}),"\n",(0,s.jsx)(t.h3,{id:"example",children:"Example"}),"\n",(0,s.jsxs)(t.p,{children:["In the ",(0,s.jsx)(t.code,{children:"jest.config.js"})," version, you could do as in the ",(0,s.jsx)(t.code,{children:"package.json"})," version of the config, but extending from the preset will ensure more compatibility without any changes when updating."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-js",children:"// jest.config.js\n// Here `defaults` can be replaced with any other preset\nconst { defaults: tsjPreset } = require('ts-jest/presets')\n\nmodule.exports = {\n // [...]\n moduleFileExtensions: [...tsjPreset.moduleFileExtensions, 'html'],\n transform: {\n ...tsjPreset.transform,\n '\\\\.html$': 'ts-jest',\n },\n globals: {\n 'ts-jest': {\n stringifyContentPathRegex: /\\.html$/,\n },\n },\n}\n"})}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'// package.json\n{\n // [...]\n "jest": {\n "moduleFileExtensions": ["js", "ts", "html"],\n "transform": {\n "\\\\.(html|ts|js)$": "ts-jest"\n },\n "globals": {\n "ts-jest": {\n "stringifyContentPathRegex": "\\\\.html$"\n }\n }\n }\n}\n'})})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>a});var s=n(6540);const o={},i=s.createContext(o);function r(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]);
\ No newline at end of file
+"use strict";(self.webpackChunkts_jest_docs=self.webpackChunkts_jest_docs||[]).push([[7556],{8307:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>c,contentTitle:()=>r,default:()=>h,frontMatter:()=>i,metadata:()=>a,toc:()=>d});var s=n(4848),o=n(8453);const i={title:"Stringify content option"},r=void 0,a={id:"getting-started/options/stringifyContentPathRegex",title:"Stringify content option",description:"The stringifyContentPathRegex option has been kept for backward compatibility of HTML_TRANSFORM",source:"@site/versioned_docs/version-27.0/getting-started/options/stringifyContentPathRegex.md",sourceDirName:"getting-started/options",slug:"/getting-started/options/stringifyContentPathRegex",permalink:"/ts-jest/docs/27.0/getting-started/options/stringifyContentPathRegex",draft:!1,unlisted:!1,editUrl:"https://github.com/kulshekhar/ts-jest/edit/main/website/versioned_docs/version-27.0/getting-started/options/stringifyContentPathRegex.md",tags:[],version:"27.0",lastUpdatedBy:"renovate[bot]",lastUpdatedAt:1726768481e3,frontMatter:{title:"Stringify content option"}},c={},d=[{value:"Example",id:"example",level:3}];function l(e){const t={code:"code",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["The ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," option has been kept for backward compatibility of ",(0,s.jsx)(t.code,{children:"__HTML_TRANSFORM__"}),"\nIt's a regular expression pattern used to match the path of file to be transformed.\nIf it matches, the file will be exported as a module exporting its content."]}),"\n",(0,s.jsxs)(t.p,{children:["Let's say for example that you have a file ",(0,s.jsx)(t.code,{children:"foo.ts"})," which contains ",(0,s.jsx)(t.code,{children:'export default "bar"'}),", and your ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," is set to ",(0,s.jsx)(t.code,{children:"foo\\\\.ts$"}),", the resulting module won't be the result of compiling ",(0,s.jsx)(t.code,{children:"foo.ts"})," source, but instead it'll be a module which exports the string ",(0,s.jsx)(t.code,{children:'"export default \\"bar\\""'}),"."]}),"\n",(0,s.jsxs)(t.p,{children:[(0,s.jsx)(t.strong,{children:"CAUTION"}),": Whatever file(s) you want to match with ",(0,s.jsx)(t.code,{children:"stringifyContentPathRegex"})," pattern, you must ensure the Jest ",(0,s.jsx)(t.code,{children:"transform"})," option pointing to ",(0,s.jsx)(t.code,{children:"ts-jest"})," matches them. You may also have to add the extension(s) of this/those file(s) to ",(0,s.jsx)(t.code,{children:"moduleFileExtensions"})," Jest option."]}),"\n",(0,s.jsx)(t.h3,{id:"example",children:"Example"}),"\n",(0,s.jsxs)(t.p,{children:["In the ",(0,s.jsx)(t.code,{children:"jest.config.js"})," version, you could do as in the ",(0,s.jsx)(t.code,{children:"package.json"})," version of the config, but extending from the preset will ensure more compatibility without any changes when updating."]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-js",children:"// jest.config.js\n// Here `defaults` can be replaced with any other preset\nconst { defaults: tsjPreset } = require('ts-jest/presets')\n\nmodule.exports = {\n // [...]\n moduleFileExtensions: [...tsjPreset.moduleFileExtensions, 'html'],\n transform: {\n ...tsjPreset.transform,\n '\\\\.html$': 'ts-jest',\n },\n globals: {\n 'ts-jest': {\n stringifyContentPathRegex: /\\.html$/,\n },\n },\n}\n"})}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-json",children:'// package.json\n{\n // [...]\n "jest": {\n "moduleFileExtensions": ["js", "ts", "html"],\n "transform": {\n "\\\\.(html|ts|js)$": "ts-jest"\n },\n "globals": {\n "ts-jest": {\n "stringifyContentPathRegex": "\\\\.html$"\n }\n }\n }\n}\n'})})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(l,{...e})}):l(e)}},8453:(e,t,n)=>{n.d(t,{R:()=>r,x:()=>a});var s=n(6540);const o={},i=s.createContext(o);function r(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function a(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:r(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]);
\ No newline at end of file
diff --git a/assets/js/270520cb.58971f6d.js b/assets/js/270520cb.aa01dd3e.js
similarity index 99%
rename from assets/js/270520cb.58971f6d.js
rename to assets/js/270520cb.aa01dd3e.js
index 5b1f98c8c8..e105e4b0b8 100644
--- a/assets/js/270520cb.58971f6d.js
+++ b/assets/js/270520cb.aa01dd3e.js
@@ -1 +1 @@
-"use strict";(self.webpackChunkts_jest_docs=self.webpackChunkts_jest_docs||[]).push([[3110],{1282:(t,e,s)=>{s.r(e),s.d(e,{assets:()=>u,contentTitle:()=>l,default:()=>j,frontMatter:()=>a,metadata:()=>c,toc:()=>d});var n=s(4848),o=s(8453),r=s(9489),i=s(7227);const a={title:"TypeScript Config option"},l=void 0,c={id:"getting-started/options/tsconfig",title:"TypeScript Config option",description:"The tsconfig option allows you to define which tsconfig JSON file to use. An inline compiler options object can also be specified instead of a file path.",source:"@site/versioned_docs/version-29.0/getting-started/options/tsconfig.md",sourceDirName:"getting-started/options",slug:"/getting-started/options/tsconfig",permalink:"/ts-jest/docs/29.0/getting-started/options/tsconfig",draft:!1,unlisted:!1,editUrl:"https://github.com/kulshekhar/ts-jest/edit/main/website/versioned_docs/version-29.0/getting-started/options/tsconfig.md",tags:[],version:"29.0",lastUpdatedBy:"renovate[bot]",lastUpdatedAt:1726767874e3,frontMatter:{title:"TypeScript Config option"}},u={},d=[{value:"Examples",id:"examples",level:3},{value:"Path to a tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function p(t){const e={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,o.R)(),...t.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(e.p,{children:["The ",(0,n.jsx)(e.code,{children:"tsconfig"})," option allows you to define which ",(0,n.jsx)(e.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,n.jsxs)(e.p,{children:["By default ",(0,n.jsx)(e.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,n.jsx)(e.code,{children:"ES2015"})," is used as ",(0,n.jsx)(e.code,{children:"target"})," instead of ",(0,n.jsx)(e.code,{children:"ES5"}),"."]}),"\n",(0,n.jsxs)(e.p,{children:["If you need to use defaults and force ",(0,n.jsx)(e.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,n.jsx)(e.code,{children:"false"}),"."]}),"\n",(0,n.jsx)(e.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(e.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,n.jsx)(e.code,{children:"tsconfig"})," file"]}),"\n",(0,n.jsxs)(e.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(e.code,{children:"tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function p(t){const e={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,o.R)(),...t.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(e.p,{children:["The ",(0,n.jsx)(e.code,{children:"tsconfig"})," option allows you to define which ",(0,n.jsx)(e.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,n.jsxs)(e.p,{children:["By default ",(0,n.jsx)(e.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,n.jsx)(e.code,{children:"ES2015"})," is used as ",(0,n.jsx)(e.code,{children:"target"})," instead of ",(0,n.jsx)(e.code,{children:"ES5"}),"."]}),"\n",(0,n.jsxs)(e.p,{children:["If you need to use defaults and force ",(0,n.jsx)(e.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,n.jsx)(e.code,{children:"false"}),"."]}),"\n",(0,n.jsx)(e.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(e.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,n.jsx)(e.code,{children:"tsconfig"})," file"]}),"\n",(0,n.jsxs)(e.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(e.code,{children:"mocked<T>(item: T, deep = false)
",id:"mockedtitem-t-deep--false",level:2},{value:"Example",id:"example",level:3}];function a(e){const t={code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,n.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.p,{children:[(0,o.jsx)(t.code,{children:"ts-jest"})," provides some test utilities to be used in your test, related to TypeScript."]}),"\n",(0,o.jsx)(t.h2,{id:"mockedtitem-t-deep--false",children:(0,o.jsx)(t.code,{children:"mockedmocked<T>(item: T, deep = false)
",id:"mockedtitem-t-deep--false",level:2},{value:"Example",id:"example",level:3}];function a(e){const t={code:"code",h2:"h2",h3:"h3",p:"p",pre:"pre",strong:"strong",...(0,n.R)(),...e.components};return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsxs)(t.p,{children:[(0,o.jsx)(t.code,{children:"ts-jest"})," provides some test utilities to be used in your test, related to TypeScript."]}),"\n",(0,o.jsx)(t.h2,{id:"mockedtitem-t-deep--false",children:(0,o.jsx)(t.code,{children:"mockednamespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val = tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function p(t){const e={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,o.R)(),...t.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(e.p,{children:["The ",(0,n.jsx)(e.code,{children:"tsconfig"})," option allows you to define which ",(0,n.jsx)(e.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,n.jsxs)(e.p,{children:["By default ",(0,n.jsx)(e.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,n.jsx)(e.code,{children:"ES2015"})," is used as ",(0,n.jsx)(e.code,{children:"target"})," instead of ",(0,n.jsx)(e.code,{children:"ES5"}),"."]}),"\n",(0,n.jsxs)(e.p,{children:["If you need to use defaults and force ",(0,n.jsx)(e.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,n.jsx)(e.code,{children:"false"}),"."]}),"\n",(0,n.jsx)(e.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(e.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,n.jsx)(e.code,{children:"tsconfig"})," file"]}),"\n",(0,n.jsxs)(e.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(e.code,{children:"tsconfig
file",id:"path-to-a-tsconfig-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4},{value:"Disable auto-lookup",id:"disable-auto-lookup",level:4}];function p(t){const e={a:"a",code:"code",h3:"h3",h4:"h4",p:"p",pre:"pre",...(0,o.R)(),...t.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(e.p,{children:["The ",(0,n.jsx)(e.code,{children:"tsconfig"})," option allows you to define which ",(0,n.jsx)(e.code,{children:"tsconfig"})," JSON file to use. An inline ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"})," object can also be specified instead of a file path."]}),"\n",(0,n.jsxs)(e.p,{children:["By default ",(0,n.jsx)(e.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project. If it cannot find one, it will use the default TypeScript ",(0,n.jsx)(e.a,{href:"https://www.typescriptlang.org/docs/handbook/compiler-options.html#compiler-options",children:"compiler options"}),"; except, ",(0,n.jsx)(e.code,{children:"ES2015"})," is used as ",(0,n.jsx)(e.code,{children:"target"})," instead of ",(0,n.jsx)(e.code,{children:"ES5"}),"."]}),"\n",(0,n.jsxs)(e.p,{children:["If you need to use defaults and force ",(0,n.jsx)(e.code,{children:"ts-jest"})," to use the defaults even if there is a ",(0,n.jsx)(e.code,{children:"tsconfig.json"})," in your project, you can set this option to ",(0,n.jsx)(e.code,{children:"false"}),"."]}),"\n",(0,n.jsx)(e.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(e.h4,{id:"path-to-a-tsconfig-file",children:["Path to a ",(0,n.jsx)(e.code,{children:"tsconfig"})," file"]}),"\n",(0,n.jsxs)(e.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(e.code,{children:"babelrc
file",id:"use-default-babelrc-file",level:4},{value:"Path to a babelrc
file",id:"path-to-a-babelrc-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4}];function d(e){const t={a:"a",code:"code",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"ts-jest"})," by default does ",(0,n.jsx)(t.strong,{children:"NOT"})," use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ",(0,n.jsx)(t.code,{children:"ts-jest"})," can call the BabelJest processor once TypeScript has transformed the source into JavaScript."]}),"\n",(0,n.jsxs)(t.p,{children:["The option is ",(0,n.jsx)(t.code,{children:"babelConfig"})," and it works pretty much as the ",(0,n.jsx)(t.code,{children:"tsconfig"})," option, except that it is disabled by default. Here is the possible values it can take:"]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"false"}),": the default, disables the use of Babel"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"true"}),": enables Babel processing. ",(0,n.jsx)(t.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(t.code,{children:".babelrc"}),", ",(0,n.jsx)(t.code,{children:".babelrc.js"}),", ",(0,n.jsx)(t.code,{children:"babel.config.js"})," file or a ",(0,n.jsx)(t.code,{children:"babel"})," section in the ",(0,n.jsx)(t.code,{children:"package.json"})," file of your project and use it as the config to pass to ",(0,n.jsx)(t.code,{children:"babel-jest"})," processor."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"{ ... }"}),": inline ",(0,n.jsx)(t.a,{href:"https://babeljs.io/docs/en/next/options",children:"Babel options"}),". You can also set this to an empty object (",(0,n.jsx)(t.code,{children:"{}"}),") so that the default Babel config file is not used."]}),"\n"]}),"\n",(0,n.jsx)(t.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(t.h4,{id:"use-default-babelrc-file",children:["Use default ",(0,n.jsx)(t.code,{children:"babelrc"})," file"]}),"\n",(0,n.jsxs)(o.A,{groupId:"code-examples",children:[(0,n.jsx)(a.A,{value:"js",label:"JavaScript",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-js",metastring:"tab",children:"// jest.config.js\n/** @type {import('ts-jest').JestConfigWithTsJest} */\nmodule.exports = {\n // [...]\n transform: {\n // '^.+\\\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`\n // '^.+\\\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n '^.+\\\\.tsx?$': [\n 'ts-jest',\n {\n babelConfig: true,\n },\n ],\n },\n}\n"})})}),(0,n.jsx)(a.A,{value:"ts",label:"TypeScript",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",metastring:"tab",children:"// jest.config.ts\nimport type { JestConfigWithTsJest } from 'ts-jest'\n\nconst jestConfig: JestConfigWithTsJest = {\n // [...]\n transform: {\n // '^.+\\\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`\n // '^.+\\\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n '^.+\\\\.tsx?$': [\n 'ts-jest',\n {\n babelConfig: true,\n },\n ],\n },\n}\n\nexport default jestConfig\n"})})}),(0,n.jsx)(a.A,{value:"JSON",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-JSON",metastring:"tab",children:'// package.json\n{\n // [...]\n "jest": {\n "transform": {\n // \'^.+\\\\.[tj]sx?$\' to process ts,js,tsx,jsx with `ts-jest`\n // \'^.+\\\\.m?[tj]sx?$\' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n "^.+\\\\.tsx?$": [\n "ts-jest",\n {\n "babelConfig": true\n }\n ]\n }\n }\n}\n'})})})]}),"\n",(0,n.jsxs)(t.h4,{id:"path-to-a-babelrc-file",children:["Path to a ",(0,n.jsx)(t.code,{children:"babelrc"})," file"]}),"\n",(0,n.jsxs)(t.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(t.code,{children:"\\babelrc
file",id:"use-default-babelrc-file",level:4},{value:"Path to a babelrc
file",id:"path-to-a-babelrc-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4}];function d(e){const t={a:"a",code:"code",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,r.R)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(t.p,{children:[(0,n.jsx)(t.code,{children:"ts-jest"})," by default does ",(0,n.jsx)(t.strong,{children:"NOT"})," use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ",(0,n.jsx)(t.code,{children:"ts-jest"})," can call the BabelJest processor once TypeScript has transformed the source into JavaScript."]}),"\n",(0,n.jsxs)(t.p,{children:["The option is ",(0,n.jsx)(t.code,{children:"babelConfig"})," and it works pretty much as the ",(0,n.jsx)(t.code,{children:"tsconfig"})," option, except that it is disabled by default. Here is the possible values it can take:"]}),"\n",(0,n.jsxs)(t.ul,{children:["\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"false"}),": the default, disables the use of Babel"]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"true"}),": enables Babel processing. ",(0,n.jsx)(t.code,{children:"ts-jest"})," will try to find a ",(0,n.jsx)(t.code,{children:".babelrc"}),", ",(0,n.jsx)(t.code,{children:".babelrc.js"}),", ",(0,n.jsx)(t.code,{children:"babel.config.js"})," file or a ",(0,n.jsx)(t.code,{children:"babel"})," section in the ",(0,n.jsx)(t.code,{children:"package.json"})," file of your project and use it as the config to pass to ",(0,n.jsx)(t.code,{children:"babel-jest"})," processor."]}),"\n",(0,n.jsxs)(t.li,{children:[(0,n.jsx)(t.code,{children:"{ ... }"}),": inline ",(0,n.jsx)(t.a,{href:"https://babeljs.io/docs/en/next/options",children:"Babel options"}),". You can also set this to an empty object (",(0,n.jsx)(t.code,{children:"{}"}),") so that the default Babel config file is not used."]}),"\n"]}),"\n",(0,n.jsx)(t.h3,{id:"examples",children:"Examples"}),"\n",(0,n.jsxs)(t.h4,{id:"use-default-babelrc-file",children:["Use default ",(0,n.jsx)(t.code,{children:"babelrc"})," file"]}),"\n",(0,n.jsxs)(o.A,{groupId:"code-examples",children:[(0,n.jsx)(a.A,{value:"js",label:"JavaScript",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-js",metastring:"tab",children:"// jest.config.js\n/** @type {import('ts-jest').JestConfigWithTsJest} */\nmodule.exports = {\n // [...]\n transform: {\n // '^.+\\\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`\n // '^.+\\\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n '^.+\\\\.tsx?$': [\n 'ts-jest',\n {\n babelConfig: true,\n },\n ],\n },\n}\n"})})}),(0,n.jsx)(a.A,{value:"ts",label:"TypeScript",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-ts",metastring:"tab",children:"// jest.config.ts\nimport type { JestConfigWithTsJest } from 'ts-jest'\n\nconst jestConfig: JestConfigWithTsJest = {\n // [...]\n transform: {\n // '^.+\\\\.[tj]sx?$' to process ts,js,tsx,jsx with `ts-jest`\n // '^.+\\\\.m?[tj]sx?$' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n '^.+\\\\.tsx?$': [\n 'ts-jest',\n {\n babelConfig: true,\n },\n ],\n },\n}\n\nexport default jestConfig\n"})})}),(0,n.jsx)(a.A,{value:"JSON",children:(0,n.jsx)(t.pre,{children:(0,n.jsx)(t.code,{className:"language-JSON",metastring:"tab",children:'// package.json\n{\n // [...]\n "jest": {\n "transform": {\n // \'^.+\\\\.[tj]sx?$\' to process ts,js,tsx,jsx with `ts-jest`\n // \'^.+\\\\.m?[tj]sx?$\' to process ts,js,tsx,jsx,mts,mjs,mtsx,mjsx with `ts-jest`\n "^.+\\\\.tsx?$": [\n "ts-jest",\n {\n "babelConfig": true\n }\n ]\n }\n }\n}\n'})})})]}),"\n",(0,n.jsxs)(t.h4,{id:"path-to-a-babelrc-file",children:["Path to a ",(0,n.jsx)(t.code,{children:"babelrc"})," file"]}),"\n",(0,n.jsxs)(t.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,n.jsx)(t.code,{children:"\\babelrc
file",id:"use-default-babelrc-file",level:4},{value:"Path to a babelrc
file",id:"path-to-a-babelrc-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4}];function d(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"ts-jest"})," by default does ",(0,t.jsx)(n.strong,{children:"NOT"})," use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ",(0,t.jsx)(n.code,{children:"ts-jest"})," can call the BabelJest processor once TypeScript has transformed the source into JavaScript."]}),"\n",(0,t.jsxs)(n.p,{children:["The option is ",(0,t.jsx)(n.code,{children:"babelConfig"})," and it works pretty much as the ",(0,t.jsx)(n.code,{children:"tsconfig"})," option, except that it is disabled by default. Here is the possible values it can take:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"false"}),": the default, disables the use of Babel"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"true"}),": enables Babel processing. ",(0,t.jsx)(n.code,{children:"ts-jest"})," will try to find a ",(0,t.jsx)(n.code,{children:".babelrc"}),", ",(0,t.jsx)(n.code,{children:".babelrc.js"}),", ",(0,t.jsx)(n.code,{children:"babel.config.js"})," file or a ",(0,t.jsx)(n.code,{children:"babel"})," section in the ",(0,t.jsx)(n.code,{children:"package.json"})," file of your project and use it as the config to pass to ",(0,t.jsx)(n.code,{children:"babel-jest"})," processor."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"{ ... }"}),": inline ",(0,t.jsx)(n.a,{href:"https://babeljs.io/docs/en/next/options",children:"Babel options"}),". You can also set this to an empty object (",(0,t.jsx)(n.code,{children:"{}"}),") so that the default Babel config file is not used."]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,t.jsxs)(n.h4,{id:"use-default-babelrc-file",children:["Use default ",(0,t.jsx)(n.code,{children:"babelrc"})," file"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:"// jest.config.js\nmodule.exports = {\n // [...]\n globals: {\n 'ts-jest': {\n babelConfig: true,\n },\n },\n}\n"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'// package.json\n{\n // [...]\n "jest": {\n "globals": {\n "ts-jest": {\n "babelConfig": true\n }\n }\n }\n}\n'})}),"\n",(0,t.jsxs)(n.h4,{id:"path-to-a-babelrc-file",children:["Path to a ",(0,t.jsx)(n.code,{children:"babelrc"})," file"]}),"\n",(0,t.jsxs)(n.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,t.jsx)(n.code,{children:"\\babelrc
file",id:"use-default-babelrc-file",level:4},{value:"Path to a babelrc
file",id:"path-to-a-babelrc-file",level:4},{value:"Inline compiler options",id:"inline-compiler-options",level:4}];function d(e){const n={a:"a",code:"code",h3:"h3",h4:"h4",li:"li",p:"p",pre:"pre",strong:"strong",ul:"ul",...(0,o.R)(),...e.components};return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)(n.p,{children:[(0,t.jsx)(n.code,{children:"ts-jest"})," by default does ",(0,t.jsx)(n.strong,{children:"NOT"})," use Babel. But you may want to use it, especially if your code rely on Babel plugins to make some transformations. ",(0,t.jsx)(n.code,{children:"ts-jest"})," can call the BabelJest processor once TypeScript has transformed the source into JavaScript."]}),"\n",(0,t.jsxs)(n.p,{children:["The option is ",(0,t.jsx)(n.code,{children:"babelConfig"})," and it works pretty much as the ",(0,t.jsx)(n.code,{children:"tsconfig"})," option, except that it is disabled by default. Here is the possible values it can take:"]}),"\n",(0,t.jsxs)(n.ul,{children:["\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"false"}),": the default, disables the use of Babel"]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"true"}),": enables Babel processing. ",(0,t.jsx)(n.code,{children:"ts-jest"})," will try to find a ",(0,t.jsx)(n.code,{children:".babelrc"}),", ",(0,t.jsx)(n.code,{children:".babelrc.js"}),", ",(0,t.jsx)(n.code,{children:"babel.config.js"})," file or a ",(0,t.jsx)(n.code,{children:"babel"})," section in the ",(0,t.jsx)(n.code,{children:"package.json"})," file of your project and use it as the config to pass to ",(0,t.jsx)(n.code,{children:"babel-jest"})," processor."]}),"\n",(0,t.jsxs)(n.li,{children:[(0,t.jsx)(n.code,{children:"{ ... }"}),": inline ",(0,t.jsx)(n.a,{href:"https://babeljs.io/docs/en/next/options",children:"Babel options"}),". You can also set this to an empty object (",(0,t.jsx)(n.code,{children:"{}"}),") so that the default Babel config file is not used."]}),"\n"]}),"\n",(0,t.jsx)(n.h3,{id:"examples",children:"Examples"}),"\n",(0,t.jsxs)(n.h4,{id:"use-default-babelrc-file",children:["Use default ",(0,t.jsx)(n.code,{children:"babelrc"})," file"]}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-js",children:"// jest.config.js\nmodule.exports = {\n // [...]\n globals: {\n 'ts-jest': {\n babelConfig: true,\n },\n },\n}\n"})}),"\n",(0,t.jsx)(n.pre,{children:(0,t.jsx)(n.code,{className:"language-json",children:'// package.json\n{\n // [...]\n "jest": {\n "globals": {\n "ts-jest": {\n "babelConfig": true\n }\n }\n }\n}\n'})}),"\n",(0,t.jsxs)(n.h4,{id:"path-to-a-babelrc-file",children:["Path to a ",(0,t.jsx)(n.code,{children:"babelrc"})," file"]}),"\n",(0,t.jsxs)(n.p,{children:["The path should be relative to the current working directory where you start Jest from. You can also use ",(0,t.jsx)(n.code,{children:"\\namespace
",id:"no-namespace",level:4},{value:"No const enum
",id:"no-const-enum",level:4},{value:"No declaration merging (enum
, namespace
, ...)",id:"no-declaration-merging-enum-namespace-",level:4},{value:"No legacy import
/export
",id:"no-legacy-importexport",level:4},{value:"No caret type-casting with JSX enabled",id:"no-caret-type-casting-with-jsx-enabled",level:4}];function d(e){const t={a:"a",code:"code",h2:"h2",h4:"h4",hr:"hr",p:"p",pre:"pre",strong:"strong",...(0,i.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(t.p,{children:["In Sept. 2018 Babel7 got released with an interesting preset: ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),"."]}),"\n",(0,s.jsxs)(t.p,{children:["The goal is to make it easy for users using Babel to try TypeScript without moving out from Babel, just by adding a preset in their Babel config (here is the ",(0,s.jsx)(t.a,{href:"https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/",children:"MSDN blog post"})," about TypeScript and Babel 7)."]}),"\n",(0,s.jsx)(t.h2,{id:"limitations",children:"Limitations"}),"\n",(0,s.jsxs)(t.p,{children:["While ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"})," is a great preset, you must know the limitation of it. Here is what is possible with TypeScript (and ",(0,s.jsx)(t.code,{children:"ts-jest"}),"), which is not with Babel7 and ",(0,s.jsx)(t.code,{children:"@babel/preset-typescript"}),":"]}),"\n",(0,s.jsx)(t.h4,{id:"no-type-checking",children:"No type-checking"}),"\n",(0,s.jsxs)(t.p,{children:["This is the big ",(0,s.jsx)(t.strong,{children:"PRO"})," of using TypeScript vs Babel, you have type-checking out of the box."]}),"\n",(0,s.jsxs)(t.p,{children:["You'll get a more fluent TDD experience (when using ",(0,s.jsx)(t.code,{children:"ts-jest"}),") since files will be type-checked at the same time they're compiled and ran."]}),"\n",(0,s.jsx)(t.p,{children:"Here TypeScript will throw while Babel won't:"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const str: string = 42\n"})}),"\n",(0,s.jsx)(t.p,{children:'With Babel, files are transpiled as isolated modules, there is no notion of "project". With TypeScript, files are part of a project and are compiled in that scope.'}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-namespace",children:["No ",(0,s.jsx)(t.code,{children:"namespace"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"namespace app {\n export const VERSION = '1.0.0'\n export class App {\n /* ... */\n }\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-const-enum",children:["No ",(0,s.jsx)(t.code,{children:"const enum"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const enum Directions {\n Up,\n Down,\n Left,\n Right,\n}\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-declaration-merging-enum-namespace-",children:["No declaration merging (",(0,s.jsx)(t.code,{children:"enum"}),", ",(0,s.jsx)(t.code,{children:"namespace"}),", ...)"]}),"\n",(0,s.jsxs)(t.p,{children:["You won't be able to do ",(0,s.jsx)(t.a,{href:"https://www.typescriptlang.org/docs/handbook/declaration-merging.html",children:"declaration merging"}),"."]}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsxs)(t.h4,{id:"no-legacy-importexport",children:["No legacy ",(0,s.jsx)(t.code,{children:"import"}),"/",(0,s.jsx)(t.code,{children:"export"})]}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"import lib = require('lib')\n// ...\nexport = myVar\n"})}),"\n",(0,s.jsx)(t.hr,{}),"\n",(0,s.jsx)(t.h4,{id:"no-caret-type-casting-with-jsx-enabled",children:"No caret type-casting with JSX enabled"}),"\n",(0,s.jsx)(t.pre,{children:(0,s.jsx)(t.code,{className:"language-ts",children:"const val =