Skip to content

Commit

Permalink
Showing 19 changed files with 5,394 additions and 18 deletions.
20 changes: 15 additions & 5 deletions docs/user/config/babelConfig.md
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ title: Babel Config option
The option is `babelConfig` and it works pretty much as the `tsConfig` option, except that it is disabled by default. Here is the possible values it can take:

- `false`: the default, disables the use of Babel
- `true`: enables Babel processing. `ts-jest` will try to find a `.babelrc`, `.babelrc.js` file or a `babel` section in the `package.json` file of your project and use it as the config to pass to `babel-jest` processor.
- `true`: enables Babel processing. `ts-jest` will try to find a `.babelrc`, `.babelrc.js`, `babel.config.js` file or a `babel` section in the `package.json` file of your project and use it as the config to pass to `babel-jest` processor.
- `{ ... }`: inline [Babel options](https://babeljs.io/docs/en/next/options). You can also set this to an empty object (`{}`) so that the default Babel config file is not used.

### Examples
@@ -30,7 +30,7 @@ module.exports = {

</div><div class="col-md-6" markdown="block">

```js
```json5
// OR package.json
{
// [...]
@@ -63,10 +63,20 @@ module.exports = {
}
};
```

```js
// OR jest.config.js with require for babelrc
module.exports = {
// [...]
globals: {
'ts-jest': {
babelConfig: require('./babelrc.test.js'),
}
}
};
```
</div><div class="col-md-6" markdown="block">

```js
```json5
// OR package.json
{
// [...]
@@ -105,7 +115,7 @@ module.exports = {

</div><div class="col-md-6" markdown="block">

```js
```json5
// OR package.json
{
// [...]
5 changes: 3 additions & 2 deletions e2e/__helpers__/templates.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export enum PackageSets {
default = 'default',
babel7 = 'with-babel-7',
babel7StringConfig = 'with-babel-7-string-config',
typescript2_7 = 'with-typescript-2-7',
// invalid
unsupportedVersion = 'with-unsupported-version',
}
export const allValidPackageSets = [PackageSets.default, PackageSets.babel7, PackageSets.typescript2_7]
export const allPackageSetsWithPreset = [PackageSets.default, PackageSets.babel7, PackageSets.typescript2_7]
export const allValidPackageSets = [PackageSets.default, PackageSets.babel7, PackageSets.babel7StringConfig, PackageSets.typescript2_7]
export const allPackageSetsWithPreset = [PackageSets.default, PackageSets.babel7, PackageSets.babel7StringConfig, PackageSets.typescript2_7]
2 changes: 2 additions & 0 deletions e2e/__templates__/with-babel-7-string-config/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module.exports = {
}
5 changes: 5 additions & 0 deletions e2e/__templates__/with-babel-7-string-config/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
preset: 'ts-jest',
testEnvironment: 'node',
globals: { 'ts-jest': { tsConfig: {}, babelConfig: 'babel.config.js' } },
}
Loading

0 comments on commit 78a53c2

Please sign in to comment.