mattz89 / angular-testing-workshop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Angular Testing Workshop

This is the sample project for the Angular testing workshop.

The sample project includes an Angular web application and a mock RESTful API within an Nx workspace by NRWL. The Angular application uses the state and data libs to manage state and handle server communication. The state lib is built around NgRx so that the application is entirely reactive.

Prerequisites

Web: Getting Started

git clone https://github.com/onehungrymind/angular-testing-workshop.git
cd angular-testing-workshop
yarn
npm run serve:all

The serve:all command is a convenience methods that runs the other commands concurrently. You can run each command separately if you need to.

"serve:web": "ng serve --open",
"serve:api": "json-server server/db.json",
"serve:all": "concurrently \"npm run serve:api\" \"npm run serve:web\" \"npm run serve:mobile\""

The web application will open to http://localhost:4200 in your browser.

You can see the API by navigating to http://localhost:3000 in your browser.

Generate an application

Run ng g @nrwl/angular:app my-app to generate an application.

You can use any of the plugins above to generate applications as well.

When using Nx, you can create multiple applications and libraries in the same workspace.

Generate a library

Run ng g @nrwl/angular:lib my-lib to generate a library.

You can also use any of the plugins above to generate libraries as well.

Libraries are sharable across libraries and applications. They can be imported from @workshop-reactive-angular/mylib.

Development server

Run ng serve my-app for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.

Code scaffolding

Run ng g component my-component --project=my-app to generate a new component.

Build

Run ng build my-app to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.

Running unit tests

Run ng test my-app to execute the unit tests via Jest.

Run nx affected:test to execute the unit tests affected by a change.

Running end-to-end tests

Run ng e2e my-app to execute the end-to-end tests via Cypress.

Run nx affected:e2e to execute the end-to-end tests affected by a change.

Understand your workspace

Run nx dep-graph to see a diagram of the dependencies of your projects.

About


Languages

Language:TypeScript 83.7%Language:HTML 6.2%Language:SCSS 5.4%Language:JavaScript 4.7%