类型错误:configSet.processWithEsbuild 不是函数

Vyt*_*nas 9 jestjs angular ts-jest

在我迁移到 Angular 13 和 Jest 28 后,我的测试停止工作。我收到这样的错误:

Test suite failed to run

    TypeError: configSet.processWithEsbuild is not a function

    > 1 | import { ChangeDetectionStrategy, Component, ChangeDetectorRef, OnChanges, SimpleChanges, OnInit, Input } from '@angular/core';
Run Code Online (Sandbox Code Playgroud)

i进口标记红字

关于如何修复它有什么想法吗?

Mic*_*ich 16

在 Jest 配置中,transform将值更改ts-jestjest-preset-angular

即之前:

  transform: {
    '^.+\\.(ts|js|html)$': 'ts-jest'
  },
Run Code Online (Sandbox Code Playgroud)

  transform: {
    '^.+\\.(ts|js|html)$': 'jest-preset-angular'
  },
Run Code Online (Sandbox Code Playgroud)

  • 这确实有效,但为什么呢? (3认同)

小智 0

使用导入“jest-preset-Angular”;而不是导入“jest-preset-Angular/setup-jest”;