Cannot find module '@angular/core/testing' from...

Discussão em 'Angular' iniciado por Emmanuel Huff, Junho 30, 2025.

  1. Upgrading from Angular 12 to Angular 16. In the process, 100% of my tests seem to be failing. All the errors seem to signify a missing node module. I am not sure what I am missing. Any help is extremely appreciated. Thanks!

    [​IMG]

    Here is my jest.config.js:

    const path = require('path');

    module.exports = {
    preset: 'jest-preset-angular',
    setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
    testEnvironment: 'jsdom',
    transform: {
    '^.+\\.(ts|js|html)$': 'ts-jest',
    },
    moduleNameMapper: {
    '^@app/(.*)$': '<rootDir>/src/app/$1',
    '^@environments/(.*)$': '<rootDir>/src/environments/$1',
    '^@src/(.*)$': '<rootDir>/src/$1',
    '^@assets/(.*)$': '<rootDir>/src/assets/$1',
    '^@styles/(.*)$': '<rootDir>/src/styles/$1',
    },
    transformIgnorePatterns: ['node_modules/(?!.*\\.mjs$)'],
    globals: {
    'ts-jest': {
    tsconfig: '<rootDir>/tsconfig.spec.json',
    stringifyContentPathRegex: '\\.html$',
    },
    },
    globalSetup: path.resolve(__dirname, 'jest-global-setup.js'),
    resolver: path.resolve(__dirname, 'src/jest.resolver.js'),
    };


    I have tried using jest 28.0.0. Currently using 27.5.1 in jest-environment-jsdom, jest in my package.json

    Continue reading...

Compartilhe esta Página