Code Monkey home page Code Monkey logo

dialexa-todo's Introduction

todo-angular: understanding test-driven-developlment with Angular best practices

todo-angular: our best practices 101 project

Constructing a to-do list application utilizing Angular 2.0 and above can facilitate the acquisition of best practices for single-page applications (SPAs). This is because such an endeavor necessitates the mastery of techniques for controlling application state, managing user interactions, and developing responsive interfaces. By prioritizing the adoption of best practices, one can gain insights into not only the fundamental elements of SPA applications, but also how to ensure their security, reliability, and proper functioning.

Table of Contents

verifiy node, git, npm:

john@$ %: node -v
v18.7.0
john@$ %: npm -v
8.18.0
john@$ %: git --version
git version 2.32.1 (Apple Git-133)

important note: node is an extremely popular js runtime that is used create backend applications of all sizes, with its package manager node hosts one of the richest ecosystems for developers to jump-in and begin coding.

VSCode Extensions

This project is developed in Visual Studio Code. For the best development experience, install the following extensions:

๐Ÿ‘‰ It's highly recommended to enable "Format on Save" in Visual Studio Code. This will automatically format your source code using the provided Prettier settings and ensures a consistent style throughout the codebase.

Development

The project structure and basic concepts follow the Medium article How to architect epic Angular app in less than 10 minutes!.

To get more help on the Angular CLI use ng help or go check out the Angular CLI Overview and Command Reference page.

2.initialize our first angular app

mkdir todo-angular && cd todo-angular
npm install -g @angular/cli

Angular CLI commands all start with ng, followed by what you'd like the CLI to do. In the Desktop directory, use the following ng new command to create a new application called todo:

ng new todo --routing=false --style=scss

Navigate into your new project with the following cd command:

cd todo

To run your todo application, use ng serve:

ng serve

3.enforcing code style

TBD

4.unit testing

Let's examine the main reasons why utilizing unit testing is beneficial for your solution:

  • Enhance implementation design: One of the common pitfalls developers encounter is coding without much thought for design. However, using unit testing forces you to consider and reconsider the design, particularly when using Test-Driven Development (TDD), which has an even greater impact.

  • Facilitate refactoring: With pre-existing tests that guarantee the expected functionality, you can confidently make modifications to the code without introducing any bugs.

  • Prevent breaking functionality while adding new features: Tests can be run to ensure that any newly added features do not disrupt existing application components.

While there are numerous other benefits, these three alone can provide a significant advantage to any project, making them crucial factors to consider. If you are still unconvinced, a few more advantages are worth mentioning.

Karma

Angular uses Karma as the built in testing engine. A typical test will look something like this...

import { TestBed } from '@angular/core/testing';
import { AppComponent } from './app.component';

describe('AppComponent', () => {
  beforeEach(async () => {
    await TestBed.configureTestingModule({
      declarations: [AppComponent],
    }).compileComponents();
  });

  it('should create the app', () => {
    const fixture = TestBed.createComponent(AppComponent);
    const app = fixture.componentInstance;
    expect(app).toBeTruthy();
  });
});

dialexa-todo's People

Watchers

Aaron Tenney avatar

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.