<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Frontend Archives - Conseil HU</title>
	<atom:link href="https://hyyyanick.com/category/frontend/feed/" rel="self" type="application/rss+xml" />
	<link>https://hyyyanick.com/category/frontend/</link>
	<description>Sharing, Growing</description>
	<lastBuildDate>Thu, 21 May 2026 13:16:26 +0000</lastBuildDate>
	<language>fr-FR</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://hyyyanick.com/wp-content/uploads/2026/04/cropped-Site-logo-32x32.png</url>
	<title>Frontend Archives - Conseil HU</title>
	<link>https://hyyyanick.com/category/frontend/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Modernizing Angular Testing: From Karma/Jasmine to Vitest</title>
		<link>https://hyyyanick.com/modernizing-angular-testing-from-karma-jasmine-to-vitest/</link>
					<comments>https://hyyyanick.com/modernizing-angular-testing-from-karma-jasmine-to-vitest/#respond</comments>
		
		<dc:creator><![CDATA[Yiyan HU]]></dc:creator>
		<pubDate>Thu, 21 May 2026 12:19:32 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Unit test]]></category>
		<guid isPermaLink="false">https://hyyyanick.com/?p=75</guid>

					<description><![CDATA[<p>If you’ve worked on Angular projects long enough, you probably know Karma. It worked for years. But in modern frontend development, slow test startup, browser dependency, and awkward debugging start to feel outdated. The test framework Vitest becomes official and...</p>
<p>The post <a href="https://hyyyanick.com/modernizing-angular-testing-from-karma-jasmine-to-vitest/">Modernizing Angular Testing: From Karma/Jasmine to Vitest</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you’ve worked on Angular projects long enough, you probably know Karma.</p>



<p>It worked for years. But in modern frontend development, slow test startup, browser dependency, and awkward debugging start to feel outdated.</p>



<p>The test framework Vitest becomes official and default for new Angular projects.</p>



<p>Here is what worked and what we learned from migration.</p>



<h1 class="wp-block-heading">Why move away from Karma?</h1>



<p>To have a briefly comparaison between the two frameworks:</p>



<figure class="wp-block-table"><table class="has-fixed-layout"><thead><tr><th>Karma</th><th>Vitest</th></tr></thead><tbody><tr><td>Browser-based</td><td>Node-based</td></tr><tr><td>Slower startup</td><td>Fast startup</td></tr><tr><td>Harder debugging</td><td>Better DX with </td></tr><tr><td>Legacy Angular default</td><td>Modern ecosystem</td></tr><tr><td>Weak watch mode</td><td>Excellent watch mode</td></tr></tbody></table></figure>



<h2 class="wp-block-heading">Installation</h2>



<p>If you are using Angular, in the official documentation, we have this article helping to migrate https://angular.dev/guide/testing/migrating-to-vitest</p>



<p>I will not dive into this too much.</p>



<h2 class="wp-block-heading">Configuration</h2>



<p>After installing <strong>vitest, jsdom/ happy-dom</strong>, this is where your real experience helps. To create your <strong>vitest.config.ts</strong></p>



<p>A basic config could be like this:</p>



<pre class="wp-block-code"><code>/// &lt;reference types="vitest" />
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  plugins: &#91;tsconfigPaths()],
  test: {
    globals: true,
    environment: 'jsdom',
    setupFiles: &#91;'src/test-setup.ts']
  }
});</code></pre>



<p>Some specifique configs example:</p>



<pre class="wp-block-code"><code>test: {
        // use the following configs will improve the speed of tests
        isolate: false,
        pool: 'threads',
        css: false,
        // Test reporters (for test execution results)
        reporters: &#91;
            'default',
            &#91;'junit', { outputFile: path to the file }],
            &#91;'junit', { outputFile: path to the file }],
        ],
        // Coverage configuration (for code coverage)
        coverage: {
            provider: 'v8',
            reporter: &#91;], // file type can be 'lcov', 'text', 'cobertura'
            reportsDirectory: reportsDir,
            exclude: &#91;
                './src/test-setup.ts'
            ]
        }
    }</code></pre>



<p>Another change is in <strong>angular.json</strong> file. In addition to the documentation, we can have some other updates:</p>



<pre class="wp-block-code"><code>"test": {
          "builder": "@angular/build:unit-test",
          "options": {
            "runner": "vitest",
            "runnerConfig": "vitest.config.ts", // to tell using this config
            "coverageReporters": &#91;"html", "lcov"],
            "coverage": true,</code></pre>



<h2 class="wp-block-heading">Refactor code from Karma to Vitest</h2>



<p>In the doc, angular CLI provides <strong>ng g @schematics/angular:refactor-jasmine-vitest</strong> to globally refactor some part of code. But we still, in some cases like <a href="https://angular.dev/api/core/testing/fakeAsync"><code>fakeAsync</code></a>, <a href="https://angular.dev/api/core/testing/flush"><code>flush</code></a> or <a href="https://angular.dev/api/core/testing/waitForAsync"><code>waitForAsync</code></a>, refactor the code manually even though it covers a lot.</p>



<p>I would share some exemples later in another post.</p>



<p></p>
<p>The post <a href="https://hyyyanick.com/modernizing-angular-testing-from-karma-jasmine-to-vitest/">Modernizing Angular Testing: From Karma/Jasmine to Vitest</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hyyyanick.com/modernizing-angular-testing-from-karma-jasmine-to-vitest/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Npm install vs npm ci: why my GitLab pipeline failed</title>
		<link>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/</link>
					<comments>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/#respond</comments>
		
		<dc:creator><![CDATA[Yiyan HU]]></dc:creator>
		<pubDate>Sat, 06 Dec 2025 09:30:40 +0000</pubDate>
				<category><![CDATA[Angular]]></category>
		<category><![CDATA[Frontend]]></category>
		<category><![CDATA[Npm]]></category>
		<guid isPermaLink="false">https://hyyyanick.com/?p=1</guid>

					<description><![CDATA[<p>When working with a web developement projet, we may install packages and dependencies using npm install. However, there is another line of command npm ci that we may not be familiar with during local develepement. Personally, I found this command...</p>
<p>The post <a href="https://hyyyanick.com/usage-of-npm-install-and-npm-ci/">Npm install vs npm ci: why my GitLab pipeline failed</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>When working with a web developement projet, we may install packages and dependencies using <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm install</mark></code>. However, there is another line of command <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ci</mark></code> that we may not be familiar with during local develepement. Personally, I found this command line in Gitlab CI/CD issue report which indicated that the dependencies in package-lock.json file is not synced with package.json. It is interesting to learn new things with an error. We will discuss the difference as below.</p>



<p class="has-medium-font-size">What <strong>npm install</strong> Actually Does</p>



<p><code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm install</mark></code> always begins by reading your <strong>package.json</strong> to determine what dependencies your project needs. If a <strong>package-lock.json</strong> is present, it treats it as a suggestion—but it updates the file as well after installing all dependencies.</p>



<p>I came into a situation where I should switch <strong>.npmrc</strong> configuration according to different projets. As I installed (npm install) dependencies with other npmrc setting, my package-lock.json was replaced and was not synced with package.json file. So the issue happened in Gitlab CI/CD (<strong>Angular peer dependency mismatch</strong> issue).</p>



<pre class="wp-block-code"><code><code>npm error <mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ci can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync</mark>. Please update your lock file with npm install before continuing. npm error npm error Missing: <strong>chokidar@3.6.0</strong> from lock file npm error npm error Clean install a project</code></code></pre>



<p class="has-medium-font-size">What <strong>npm ci</strong> Actually Does</p>



<p>This issue happens especially in CI/CD environnement where <code>npm ci</code> is strict about exact dependency versions. As the error indicates, my package.json and package-lock.json are not in sync. What <code>npm ci</code> does is that it uses <code>package-lock.json</code> as the single source of truth. It removes node_modules and <strong>reinstalls packages from scratch to guarantee a clean environnement</strong>. With npm ci, the installation is faster because it skips the dependency resolution and does not check node_modules cache.</p>



<p>To fix the issue, I should just remove node_modules and package-lock.json file in my local environnement, switching to the right npmrc setting and reinstall with npm install. But somehow it failed always&#8230;</p>



<p class="has-medium-font-size">What <strong>npm ls</strong> helps</p>



<p>This annoyed me a lot. But this problem let me discovered another command line &#8211; <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ls</mark></code>. With <code>npm ls chokidar</code>, it output this error:</p>



<pre class="wp-block-code"><code>+-- @angular-devkit/build-angular@20.3.10 | +-- @angular-devkit/core@20.3.10 | | <code>-- chokidar@4.0.3 deduped </code>| +-- sass@1.90.0 | | <code>-- chokidar@4.0.3 deduped </code>| <code>-- webpack-dev-server@5.2.2 </code>| <code>-- chokidar@3.6.0 </code>+-- @angular/compiler-cli@20.3.11 | <code>-- chokidar@4.0.3 </code>+-- @schematics/angular@13.3.11 | <code>-- @angular-devkit/core@13.3.11 </code>| <code>-- chokidar@4.0.3 deduped invalid: "^3.5.2" from node_modules/@schematics/angular/node_modules/@angular-devkit/core -- karma@6.4.4</code> <code>-- chokidar@3.6.0</code>
npm error code ELSPROBLEMS 
npm error invalid: chokidar@4.0.3</code></pre>



<p>So it is clear that the chokidar version is not compatible. I fixed the chokidar version manuelly in my package.json file, removing node_modules and package-lock.json, and reinstalled all packages. Now when I checked with <code><mark style="background-color:rgba(0, 0, 0, 0);color:#ff6a00" class="has-inline-color">npm ls</mark></code>, no more conflits in dependencies installed.</p>
<p>The post <a href="https://hyyyanick.com/usage-of-npm-install-and-npm-ci/">Npm install vs npm ci: why my GitLab pipeline failed</a> appeared first on <a href="https://hyyyanick.com">Conseil HU</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://hyyyanick.com/usage-of-npm-install-and-npm-ci/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
