The most common way to test Angular 2 apps is with the Jasmine test framework. Jasmine allows you to test your code in the browser.
To get started, all you need is the jasmine-core package (not jasmine).
npm install jasmine-core --save-dev --save-exact
To verify that Jasmine is set up properly, create the file ./src/unit-tests.html with the following content and open it in the browser.
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Ng App Unit Tests</title>
<link rel="stylesheet" href="/?originalUrl=https%3A%2F%2Friptutorial.com%2F%26quot%3B..%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.css%26quot%3B%26gt%3B%2520%2520%26lt%3Bscript%2520src%3D%26quot%3B..%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine.js%26quot%3B%26gt%3B%26lt%3B%2Fscript%26gt%3B%2520%2520%26lt%3Bscript%2520src%3D%26quot%3B..%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fjasmine-html.js%26quot%3B%26gt%3B%26lt%3B%2Fscript%26gt%3B%2520%2520%26lt%3Bscript%2520src%3D%26quot%3B..%2Fnode_modules%2Fjasmine-core%2Flib%2Fjasmine-core%2Fboot.js%26quot%3B%26gt%3B%26lt%3B%2Fscript%26gt%3B%26lt%3B%2Fhead%26gt%3B%26lt%3Bbody%26gt%3B%2520%2520%2520%26lt%3B!--%2520Unit%2520Testing%2520Chapter%2520%231%3A%2520Proof%2520of%2520life.%2520%2520--%26gt%3B%2520%2520%2520%26lt%3Bscript%26gt%3B%2520%2520%2520%2520%2520it("true is true', function () {
expect(true).toEqual(true);
});
</script>
</body>
</html>