As far as I know, you can simply destructure the 'expect' function from the callback parameter object inside 'it', in order to make it work with asynchronous code. Something like this: it('should expect asynchronously', ({ expect }) => {api.getTags().subscribe((response) => { expect(response).toBeTruthy(); })}) But maybe this is just working with vitest, don't know for sure. Anyways, thanks for the content!
Thnks for video, I would say using jest-preset-angular to compile tests will end up being slower than jasmine and the advantage of using jest is no longer an advantage really, Angular added an experimental official support for jest and it uses esbuild internally which means super fast tests with Jest, why didn't you opted for that ?
I followed this video till minute 21 and I am stuck. I have this error when running the test: ({"Object.":function(module,exports,require,__dirname,__filename,jest){import { range } from './utils'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14) Test Suites: 1 failed, 1 total Tests: 0 total Snapshots: 0 total Time: 0.916 s Ran all test suites. I can't fix it. can you help me please?
Are you sure you have not nested the import-Statement somewhere? Did you correctly place the import in the beforeEach function? Any syntax errors or anything else like that?
Yes. The only difference is that standalone components are not there yet but it doesn't change anything. You inject a component in the test in another way. This is it.
Awesome! This comes to the right time :) Please keep up the great content.
Thank you so much for your support. It means a lot to me!
This is definitely the BEST course on Angular Testing. I also bought your full course.
Thank you, keep up the good work!
Glad you enjoy it!
What I enjoy about your videos is how practical they are. They have immediate use in most large-scale Angular apps. Thank you for your work.
Glad you like them!
I really like your channel!! English is very clear and pleasant to my ear, the material is served very well!
Thank you! 😃
Awesome! Do you have any advice about testing with the new features in Angular v19? Thanks!
What specifically? Testing signals is the same except of input signals. I didn't try to test defer yet.
@@MonsterlessonsAcademy Oh nice, yep about control-flow, but as you said maybe im deeping a lot in DOM and not the behaivor code Thanks!
@@devcognicion There are no changes for tests for control flow. It just works.
As far as I know, you can simply destructure the 'expect' function from the callback parameter object inside 'it', in order to make it work with asynchronous code. Something like this:
it('should expect asynchronously', ({ expect }) => {api.getTags().subscribe((response) => { expect(response).toBeTruthy(); })})
But maybe this is just working with vitest, don't know for sure. Anyways, thanks for the content!
Sure there are multiple variants to do that
Very well explained in just an hour i went from zero to being confident, however could you also suggest how to unit test the components?
I cover everything about components testing including real project testing in the full course
Awesome course, thank you
Glad you like it!
Woww!! I learned so much thank you
Glad it was helpful!
Thnks for video, I would say using jest-preset-angular to compile tests will end up being slower than jasmine and the advantage of using jest is no longer an advantage really, Angular added an experimental official support for jest and it uses esbuild internally which means super fast tests with Jest, why didn't you opted for that ?
I never felt a slowness of jest preset. I didn't use esbuild with jest because it is experimental and not something that I would put in the course.
Can you tell me please which editor you are using?
It's Vim
It lacks the link to github with this code...
It's a part of the paid course. You get access to the code under every single video inside a full course
@@MonsterlessonsAcademy Oh, I see. Thank you ☺️
I followed this video till minute 21 and I am stuck. I have this error when running the test: ({"Object.":function(module,exports,require,__dirname,__filename,jest){import { range } from './utils';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1505:14)
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.916 s
Ran all test suites. I can't fix it. can you help me please?
Unfortunately I can't help without debugging your code.
Are you sure you have not nested the import-Statement somewhere? Did you correctly place the import in the beforeEach function? Any syntax errors or anything else like that?
same error
Please upload for react too and next js.
I want also for react.
you too comment maybe he will read yours he havent replied to mine comment
Thank you. I will add it in the list of ideas for the next course
thanks a lot sir @@MonsterlessonsAcademy
Would this work with Angular 14?
Yes. The only difference is that standalone components are not there yet but it doesn't change anything. You inject a component in the test in another way. This is it.
You're a great presenter. Keep doing what you do!@@MonsterlessonsAcademy
For react will be useful also
I will add it to the list of future courses
@@MonsterlessonsAcademy a lot of thanks
thanks
Welcome
Where is the download code for the video?
source code is available in the full course
35:00
where is the source code?
As this is a part of the full course you get access to the course code of each video inside the course.