Jest-preset-angular: The configuration for astTransformers as string[] is deprecated and will be removed in ts-jest 27

Created on 11 Aug 2020  路  4Comments  路  Source: thymikee/jest-preset-angular

馃悰 Bug Report

jest --config ./jest.config.js
ts-jest[config] (WARN) The configuration for astTransformers as string[] is deprecated and will be removed in ts-jest 27. Please define your custom AST transformers in a form of an object. More information you can check online documentation https://kulshekhar.github.io/ts-jest/user/config/astTransformers
ts-jest[config] (WARN) The configuration for astTransformers as string[] is deprecated and will be removed in ts-jest 27. Please define your custom AST transformers in a form of an object. More information you can check online documentation https://kulshekhar.github.io/ts-jest/user/config/astTransformers

envinfo

System:
    OS:

Npm packages:
    jest: last
    jest-preset-angular: last
    typescript: last
Bug Confirmed

Most helpful comment

This warning is due to change in ts-jest. Reference here. It can be easily fixed by changing your jest config to something like the following:

globals: {
    'ts-jest': {
      // ...
      astTransformers: {
        before: [
          'jest-preset-angular/build/InlineFilesTransformer',
          'jest-preset-angular/build/StripStylesTransformer',
        ],
      },
    },
  },

We should change documentation in this repo.

All 4 comments

This warning is due to change in ts-jest. Reference here. It can be easily fixed by changing your jest config to something like the following:

globals: {
    'ts-jest': {
      // ...
      astTransformers: {
        before: [
          'jest-preset-angular/build/InlineFilesTransformer',
          'jest-preset-angular/build/StripStylesTransformer',
        ],
      },
    },
  },

We should change documentation in this repo.

Yes it is a change in ts-jest configuration for astTransformers.

PR is welcome :)

not sure what version worked with proposed solution, but on v26.4.0 this change to object proposed by @mmeylan throws:
```
TypeError: path.startsWith is not a function

  at ConfigSet.resolvePath (node_modules/ts-jest/dist/config/config-set.js:717:18)
  at node_modules/ts-jest/dist/config/config-set.js:175:41
      at Array.map (<anonymous>)
  at ConfigSet.get (node_modules/ts-jest/dist/config/config-set.js:174:49)
  at ConfigSet.<anonymous> (node_modules/ts-jest/dist/utils/memoize.js:44:24)
  at ConfigSet.get (node_modules/ts-jest/dist/config/config-set.js:364:37)
  at ConfigSet.<anonymous> (node_modules/ts-jest/dist/utils/memoize.js:44:24)
  at ConfigSet.get (node_modules/ts-jest/dist/config/config-set.js:583:50)
  at ConfigSet.<anonymous> (node_modules/ts-jest/dist/utils/memoize.js:44:24)
  at ConfigSet.get (node_modules/ts-jest/dist/config/config-set.js:603:25)```

if you install 8.3.1, it should fix the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jfcere picture jfcere  路  4Comments

maxencefrenette picture maxencefrenette  路  8Comments

chris5287 picture chris5287  路  7Comments

ArielGueta picture ArielGueta  路  4Comments

ilancohen picture ilancohen  路  7Comments