How do i setup Stackblitz with Angular 16 and jasmine

628 Views Asked by At

With the intention of asking a different question about Angular+Jasmine, I wanted to reproduce my failing code in StackBlitz for better reference.

There are many working examples of how to achieve this (e.g. here or here) which more or less follow the same structure as found in this guide. However, all the examples and templates I have found use rather old versions of Angular. Updating any of these examples within StackBlitz to Angular 16, by pressing the ↻ Update All to Latest button will break them, resulting most of the time in following error:

Error in polyfills.ts
The entrypoint for 'zone.js' could not successfully be resolved.
The file '/turbo_modules/[email protected]/dist/zone' does not exist.

I found out here, that replacing import 'zone.js/dist/zone'; with import 'zone.js'; might solve this problem.

However, after that i just get the next error, that i can't figure out to fix:

Error in main.ts
The entrypoint for 'jasmine-core' could not successfully be resolved.
The file '/turbo_modules/[email protected]/lib/jasmine-core/boot.js' does not exist.

When i try to import jasmineRequire from 'jasmine-core/lib/jasmine-core.js'; in WebStorm, I get the following error:

TS7016: Could not find a declaration file for module  jasmine-core/lib/jasmine-core.js

and advises to declare the module in a *.d.ts file.

I tried to do that in src/jasmine.d.ts, but it didn't help.

My attempts to reproduce my actual problem (which I will ask about in another question once I have solved this problem) can be found here on StackBlitz. I have commented out the failing parts, so you can see, that the project compiles up to the point where I try to use jasmine.

I don't know if these problems are related or not, and if this should be split into multiple questions.

I have already found this question, which only leads to one of the outdated examples I referenced earlier.

Note: I am very new to web development and this is my very first question on a StackExchange site. I hope the quality of my question isn't too bad.

Summary: How do I get the same result as seen in the outdated examples I referenced, but with Angular 16 in a project setup as seen in my Stackblitz setup?

0

There are 0 best solutions below