question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Jest warns about astTransformers as string[] deprecation

See original GitHub issue

Current Behavior

Jest warns about the 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
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
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
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
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
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

It’s one warnings per spec file.

Jest was updated to 26 as part of the 10.1.0 migration:

    "10.1.0": {
      "version": "10.1.0-beta.0",
      "packages": {
        "jest": {
          "version": "26.2.2",
          "alwaysAddToPackageJson": false
        },
        "ts-jest": {
          "version": "26.1.4",
          "alwaysAddToPackageJson": false
        },
        "@types/jest": {
          "version": "26.0.8",
          "alwaysAddToPackageJson": false
        },
        "jest-preset-angular": {
          "version": "8.2.1",
          "alwaysAddToPackageJson": false
        },
        "babel-jest": {
          "version": "26.2.2",
          "alwaysAddToPackageJson": false
        }
      }
    }

jest.config.js

module.exports = {
	preset: '../../jest.preset.js',
	coverageDirectory: '../../coverage/frontend-libs/my-project',
	snapshotSerializers: [
		'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
		'jest-preset-angular/build/AngularSnapshotSerializer.js',
		'jest-preset-angular/build/HTMLCommentSerializer.js',
	],
	setupFilesAfterEnv: ['<rootDir>/src/test-setup.ts'],
	globals: {
		'ts-jest': {
			tsConfig: '<rootDir>/tsconfig.spec.json',
			stringifyContentPathRegex: '\\.(html|svg)$',
			astTransformers: [
				'jest-preset-angular/build/InlineFilesTransformer',
				'jest-preset-angular/build/StripStylesTransformer',
			],
		},
	},
	displayName: 'my-project',
};

Expected Behavior

It should not output these many warnings. There is an older issue about this as well #3499 that says it should support Jest 26.

Ideally it shouldn’t warn at all.

Steps to Reproduce

This issue may not be prioritized if details are not provided to help us reproduce the issue.

Failure Logs

Environment

  nx : Not Found
  @nrwl/angular : 10.3.0
  @nrwl/cli : 10.3.0
  @nrwl/cypress : 10.3.0
  @nrwl/eslint-plugin-nx : Not Found
  @nrwl/express : Not Found
  @nrwl/jest : 10.3.0
  @nrwl/linter : 10.3.0
  @nrwl/nest : Not Found
  @nrwl/next : Not Found
  @nrwl/node : Not Found
  @nrwl/react : Not Found
  @nrwl/schematics : Not Found
  @nrwl/tao : 10.3.0
  @nrwl/web : Not Found
  @nrwl/workspace : 10.3.0
  typescript : 4.0.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
krokofantcommented, Oct 5, 2020

@FrozenPandaz I think you misunderstood me. I did the migration but it didn’t take, it said successful but didn’t actually make the change.

0reactions
github-actions[bot]commented, Dec 21, 2020

This issue has been automatically marked as stale because it hasn’t had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

The configuration for astTransformers as string[] is deprecated ...
jest.config.js ts-jest[config] (WARN) The configuration for astTransformers as string[] is deprecated and will be removed in ts-jest 27.
Read more >
AST transformers option | ts-jest - GitHub Pages
The option is astTransformers and it allows ones to specify which 3 types of TypeScript AST transformers to use with ts-jest : before...
Read more >
ts-jest | Yarn - Package Manager
A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript. NPM version NPM downloads Known...
Read more >
kulshekhar/ts-jest | Build 1481 | src/config/config-set.ts
The big issue is that jest calls first `getCacheKey()` with stringified. 8, * version of the `jest.ProjectConfig`, and then later it calls ...
Read more >
typeerror: cannot read property 'location' of undefined jest
Error: React.createElement: type is invalid — expected a string That was my another Jest newbie mistake, and forgot that it's all JavaScript under...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found