GithubHelp home page GithubHelp logo

Comments (11)

alan-agius4 avatar alan-agius4 commented on August 16, 2024 3

Looks like jest-preset-angular is using deep imports, instead of consuming the “public” entry-points

IE

import 'zone.js/fesm2015/zone-testing-bundle.min.js';

Instead of something like;

import 'zone.js/testing';

That being said, it’s a bit unclear how the zone-testing-bundle should be consumed.

I think as an interim for v0.13.x we could re-allow deep imports and remove them in v0.14.x.

//cc @JiaLiPassion.

from jest-preset-angular.

alan-agius4 avatar alan-agius4 commented on August 16, 2024 3

zone.js version 0.13.3 has been just released which should get around this issue.

Deep imports will eventually no longer be allowed from zone.js version 0.14.0.

The proper way to use zone testing is the following:

import "zone.js";
import "zone.js/testing";

from jest-preset-angular.

timothee-dhenain-zenika avatar timothee-dhenain-zenika commented on August 16, 2024 2

It's still an issue with the latest version of Angular (17.0.2), all of our tests are broken as well after upgrading. This is our following package.json:

"dependencies": {
    "@angular/animations": "~17.0.2",
    "@angular/common": "~17.0.2",
    "@angular/compiler": "~17.0.2",
    "@angular/core": "~17.0.2",
    "@angular/forms": "~17.0.2",
    "@angular/localize": "~17.0.2",
    "@angular/platform-browser": "~17.0.2",
    "@angular/platform-browser-dynamic": "~17.0.2",
    "@angular/router": "~17.0.2",
    "@angular/service-worker": "~17.0.2",
    "@ngrx/effects": "~16.3.0",
    "@ngrx/store": "~16.3.0",
    "rxjs": "~7.8.1",
    "tslib": "~2.6.1",
    "zone.js": "~0.14.2"
  },
  "devDependencies": {
    "@angular-builders/jest": "~16.0.0",
    "@angular-devkit/build-angular": "~17.0.0",
    "@angular-eslint/builder": "~17.0.1",
    "@angular-eslint/eslint-plugin": "~17.0.1",
    "@angular-eslint/eslint-plugin-template": "~17.0.1",
    "@angular-eslint/schematics": "~17.0.1",
    "@angular-eslint/template-parser": "~17.0.1",
    "@angular/cli": "~17.0.0",
    "@angular/compiler-cli": "~17.0.2",
    "@types/jest": "~29.5.3",
    "jest": "~29.6.2",
    "jest-canvas-mock": "~2.5.2",
    "jest-preset-angular": "~13.1.3",
    "typescript": "~5.2.2",
  }

And our angular.json configuration:

"test": {
        "builder": "@angular-builders/jest:run",
        "options": {
          "tsConfig": "tsconfig.spec.json",
          "configPath": "jest.config.js",
          "assets": ["src/favicon.ico", "src/assets"],
          "styles": ["src/styles.scss"],
          "scripts": []
        }
      },

FAIL src/app/shared/components/features/search/components/search-companies/components/search-companies-by-id/pipe/search-companies-by-id-placeholder.pipe.spec.ts
● Test suite failed to run

Cannot find module 'zone.js/bundles/zone-testing-bundle.umd' from 'node_modules/@angular-builders/jest/node_modules/jest-preset-angular/setup-jest.js'

Require stack:
  node_modules/@angular-builders/jest/node_modules/jest-preset-angular/setup-jest.js
  node_modules/@angular-builders/jest/dist/jest-config/setup.js

from jest-preset-angular.

Tallyb avatar Tallyb commented on August 16, 2024 1

#2162

from jest-preset-angular.

ghiscoding avatar ghiscoding commented on August 16, 2024 1

indeed the temp fix seems to work now, but I guess it's probably better to keep this issue open until a proper fix is implemented. Thanks for the info and quick turnaround about the Angular upstream :)

from jest-preset-angular.

alexus85 avatar alexus85 commented on August 16, 2024 1

updating to the latest version (13.1.4) seem to have solved the issue for me.

from jest-preset-angular.

karoldydo avatar karoldydo commented on August 16, 2024 1

Update package "@angular-builders/jest": "^17.0.0" solve the problem.

from jest-preset-angular.

ocombe avatar ocombe commented on August 16, 2024

I have the same error, everything was working fine last night, and now all of my tests are broken https://github.com/teambit/envs-health-status/actions/runs/6153094762/job/16696392467

from jest-preset-angular.

ocombe avatar ocombe commented on August 16, 2024

zone.js/bundles/zone-testing-bundle.umd has been renamed zone.js/bundles/zone-testing.umd in the last package

from jest-preset-angular.

Sebastian-G avatar Sebastian-G commented on August 16, 2024

Also occurs for new angular builders:

       "test": {
          "builder": "@angular-builders/jest:run",
          "options": {
            "tsConfig": "tsconfig.spec.json",
            "polyfills": ["zone.js", "zone.js/testing"]
          }
        }

fixed by enforcing zone.js version 0.13.1

from jest-preset-angular.

SmailHammour avatar SmailHammour commented on August 16, 2024

Since Angular v17 will require Zone.js version 0.14.x or later, this is still an issue?

from jest-preset-angular.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.