SlideShare a Scribd company logo
Frontend Architecture and Jest
Goals
❏ Help the team:
❏ To take better decisions in frontend architecture
❏ To think about frontend design code
❏ Setup tests
❏ To make better unit tests
Frontend
Architecture
Coincidence Programming
Architecture
Layers Architecture
Abstraction
logic not
related to UI
State
Management
Async
Services Service Layer
Presentation
Module A
Presentation
Module B
Presentation/
View Layer
Layers Architecture
❏ Isolated UI logic from others logic
❏ Easier to test
❏ Easier to maintain
❏ SOC
❏ Control the application state in a simple way - No NgRx
(Angular Redux)
Components
Presentation
Module
Containers or
Smart
Components
1 … N
Dumb
components
Dumb
components
Dumb
components
Smart components
❏ Services Injected
❏ Know how to get the data
❏ Pass data to the dumb components
❏ react to the events from dumb components
❏ Are top-level routable components (but not always!).
Dumb/Presentational
Components
❏ should not be dependant on external services
❏ Should be predictable - not produce any side effects
❏ Should not mutate its’ inputs — because if it does, it actually
produces a side effect - a child should never directly edit
parent’s data.
Binding
Module
❏ An application is made up of several blocks, which are
ngModules or modules.
❏ Give context for our components to run
❏ Correct use of modules has a positive impact on application
performance through the use of Lazy Loading.
❏ Angular Modules: BrowserModule, CommonModule,
HttpClientModule, RouterModule, FormsModule and
ReactiveFormsModule
Module Options
❏ Declarations - where we put our components, directives, pipes
and masks - the things related with the module itself
❏ Imports - to import another modules with services, pipe,
components and others resources. The dependencies
necessary on the module
❏ Exports - public components, submodules, directives, etc to be
used in others module
❏ entryComponents - components not linked with routes or
bootstrap in app module - example: modals
Architecture Modules
❏ Coreservices Module - All services that are singleton and global
(interceptor, guards, ). - optional
❏ SharedModule - Shared components, directives, pipes, masks
between the various application modules.
❏ Layout Module - Components that are the basis for the entire
application (eg header, menu-aside, footer)
❏ FeatureModule - Module by Feature
❏ AppRoutingModule - Main Routing Module
❏ FeatureRoutingModule - sub-module of a feature
❏ CoreModule and LayoutModule can only be imported once
Services - Singleton
Component
When I get an US...
❏ Check the requirements and what is necessary to do
❏ See if the US is possible to be developed
❏ Create your own checklist
❏ Which module?
❏ Do I need to create components?
❏ Presentational component or smart component? Or both?
❏ What is UI logic and what is not?
❏ What kind of services do I need?
Jest
What is
Jest is a delightful
JavaScript Testing
Framework with a focus on
simplicity.
It works with projects
using: Babel, TypeScript,
Node, React, Angular, Vue
and more!
Made on top of Jasmine
Why to Use?
❏ Easy to config and setup tests in most projects
❏ Focuses on Developer Experience (speed and ease of use is the
first priority.)
❏ Isolated and high performance to execute
❏ Tests run in parallel
❏ It has a really good documentation
❏ The API is richer than Jasmine
❏ rerun instantly only tests related to latest code changes
❏ Abstracting the DOM with jsdom library - don't use a headless
browser
Watch Mode
Tests Doubles
Mock x Stub x Spy
❏ It is very rare that the units we are testing do not have
dependencies
❏ "Test Double is a generic term for any case where you
replace a production object for testing purposes". Martin
Fowler
Mock
❏ Mocks fake something - its a copy
❏ Avoid flaky testing not calling
something with side effect - like
HTTP requests
❏ Mock is the simplest way to fake
something
Mock
import {LoginComponent} from
'./login.component';
class MockAuthService {
authenticated = false;
isAuthenticated() {
return this.authenticated;
}
}
Use Mock
describe('Component: Login', () => {
let component: LoginComponent;
let service: MockAuthService;
beforeEach(() => { (2)
service = new MockAuthService();
component = new LoginComponent(service);
});
afterEach(() => {
service = null;
component = null;
});
it('canLogin returns false when the user
is not authenticated', () => {
service.authenticated = false; (3)
expect(component.needsLogin()).toBeTruthy()
;
});
it('canLogin returns false when the user
is not authenticated', () => {
service.authenticated = true; (3)
expect(component.needsLogin()).toBeFalsy();
});
});
Spy
❏ The main benefit of spies is that they allow to watch how the
function is used.
❏ We use spies when we want to track:
❏ if a inside function has been called into another function,
❏ how many times it has been called,
❏ which arguments were passed.
Spy
describe('MyService', () => {
let service;
let someService;
let spy;
class SomeService {
getValue = function() {};
}
beforeEach(() => {
someService = new SomeService();
service = new MyService(someService);
});
it('#getValue should return value', () => {
spy = jest.spyOn(someService, 'getValue');
spy.mockReturnValue('stub value');
expect(service.getValue()).toBe('stub value');
expect(spy).toHaveBeenCalled();
});
Stub
❏ Its a spy evolution
❏ So a stub is a function that replaces a real implementation of
an existing function.
❏ We use stubs if we want to:
❏ control individual method behavior for a specific test case,
❏ prevent a method from making side effects like
communicating with the outside world using Angular's
HttpClient.
❏ Checks our application behavior/response/outcome under
certain scenarios
❏ In jest we use mockImplementation
Service to stub
@Injectable({ provideIn: 'root' })
export class LocalStorageWrapperService {
constructor() { }
private localStorage = localStorage;
remove(key) {
return this.localStorage.removeItem(key);
}
get(key) {
try {
return JSON.parse(this.localStorage.getItem(key));
} catch (e) {
return null;
}
}
set(key, value) {
return localStorage.setItem(key, JSON.stringify(value));
Stub
@Injectable()
export class LocalStorageWrapperStubService {
constructor() { }
private localStorage = new Map();
remove(key) {
return this.localStorage.delete(key);
}
get(key) {
try {
return this.localStorage.get(key);
} catch (e) {
return null;
}
}
set(key, value) {
return this.localStorage.set(key, JSON.stringify(value));
}
Jasmine x
Jest❏ Unfriendly errors logs
❏ No code coverage include
❏ Runs tests runs sequentially
❏ Hard to run tests headless
❏ It’s already configured with
Angular - more examples and
code on the internet
❏ Great exceptions and logs
when tests fail
❏ Code coverage without any
additional setup
❏ Run tests in parallel
❏ Run 2.5x times faster than
Jasmine
❏ Tests headless by default
❏ Has all jasmine matchers and
include many more
❏ Has snapshot tests
Jasmine x
Jest❏ jasmine.createSpy()
❏ jasmine.createSpyObj('name',
['key'])
❏ jasmine.createSpy().and.retur
nValue()
❏ spyOn(...).and.callFake(() =>
{})
❏ jest.fn()
❏ jest.fn({key: jest.fn()}
❏ jest.fn().mockReturnValue(‘’)
❏ jest.spyOn(...).mockImplemen
tation(() => {})
Testing in
Angular
TestBed
❏ Every component need to run with a context (module and
dependencies)
❏ TestBed create the setup necessary to the component run
describe('AppComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
RouterTestingModule
],
declarations: [
AppComponent
],
}).compileComponents();
}));
Use the testing modules
library
❏ Instead of HttpClientModule use HttpClientTestingModule
❏ Instead of RouterModule use RouterTestingModule
❏ Instead of AnimationsModule use NoopAnimationsModule
❏ Always try to find a testing module to avoid side effects
Unit Testing
❏ Testing one thing at a time, tests should not care about the
points of interaction between different units of the application
❏ In Angular can be splitting into:
❏ Isolated - when we just test component functions.
❏ shallow unit tests - testing components template without
rendering its children. It may be achieved by simply not
registering child components inside of the TestBed
function.
Integration test?
Integration test
❏ Checking that multiples units are interacting with each other
correctly
❏ Use:
❏ When the integration between components is needed for
creating a meaningful test
❏ Testing DOM with a simple interaction involving multiple
components
❏ When testing integrations with third-party libraries
Snapshot
❏ It’s good for black box testing
❏ You can use snapshot tests based on some inputs
❏ Snapshots should be deterministic
❏ You can run multiple times the same test and won’t fail
❏ Use consistent values: Date.now = jest.fn(() =>
1482363367071);
❏ You can use snapshots for:
❏ Templates HTML - Dumb components
❏ JavaScript Lists and Objects
Snapshot
Snapshot - inline DOM
it('Snapshot of html component=', () => {
const fixture = TestBed.createComponent(AppComponent);
const ulList = fixture.debugElement.nativeElement.querySelector('.ul-
list');
expect(ulList).toMatchSnapshot('AppComponent ul-list');
});
Jest x Jasmine
❏ Jasmine and Jest API it's not that different.
❏ If we know how to test in Angular we know how to test in Jest
The unit test shoudn’t be
hard
Avoid side effects
Testing Module
@NgModule({
declarations: [],
imports: [
CommonModule,
NoopAnimationsModule,
HttpClientTestingModule,
RouterTestingModule,
],
// Tells the compiler not to error on unknown elements and attributes
schemas: [NO_ERRORS_SCHEMA]
providers: [
{ provide: SystemSettingsService, useClass: SystemSettingsServiceStub },
{ provide: LocalStorageWrapperService, useClass: LocalStorageWrapperServiceStub }
]
})
Using Testing Module
describe('LoginComponent', () => {
let component: LoginComponent;
let fixture: ComponentFixture<LoginComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
imports: [
AuthModule,
TestingModule,
],
})
.compileComponents();
}));
Stick to black-box testing:
Test only public methods
Group your tests
❏ Group by type of tests (DOM tests, black box tests, integration
tests, snapshot tests and component tests)
❏ Each group of test may have your own beforeEach - tests run
faster
Group your tests
describe('DummyComponent.spec', () => {
beforeEach(() => {
// Setup Tests
})
describe('DOM Tests', () => {
it('Test Something', () => {
// ...
})
})
})
Clear mocks
beforeEach(() => {
jest.clearAllMocks();
});
What to test
❏ Navigation
❏ Set a guard and check if only logged users can access a
route
❏ Something happened and then the navigation occurs
❏ 404 view
❏ If someone type something wrong on URL goes to login
What to test?
❏ Services
❏ to HTTP requests use HTTPTestingModule and check if the
URL is correct called, queryParams based on inputs, if the
payload will be transform into a intance of something
❏ It's easy to test because you don't have the DOM
❏ That's why architecture matter - UI logic stay on
component and the rest in services
What to test?
❏ Component.ts
❏ Check if the component is running correctly
❏ Testing public methods
❏ If it has forms use reactive forms - easier to test
❏ Take snapshots
❏ List of objects
❏ Dumb components - DOM
❏ Any important logic. ex: data transformation to show on
the UI
What to test?
❏ DOM
❏ Rules - not ngIf itself, but the rule
❏ Use DebugElement
❏ How something appear in the view
❏ Use fixture.detectChanges() correctly
it('should find the <p> with fixture.debugElement.nativeElement)', () => {
const bannerDe: DebugElement = fixture.debugElement;
const bannerEl: HTMLElement = bannerDe.nativeElement;
const p = bannerEl.querySelector('p');
expect(p.textContent).toEqual('banner works!');
});
Plus: One E2E smoke test
it('When doing smoke testing over all page, should load them all
successfully', () => {
// exemplified using Cypress but can be implemented easily
// using any E2E suite
cy.visit('https://mysite.com/home');
cy.contains('Home');
cy.contains('https://mysite.com/Login');
cy.contains('Login');
cy.contains('https://mysite.com/About');
cy.contains('About');
})
Plus2: Good Tests Examples
https://codecraft.tv/courses/angular/unit-testing/overview/
Exercise
https://github.com/adrianlemess/frontend-components-jest-
training

More Related Content

What's hot

Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
Iakiv Kramarenko
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
Michael Haberman
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
Iakiv Kramarenko
 
Testing 101
Testing 101Testing 101
Testing 101
Mike Francis
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with MockitoRichard Paul
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
Tania Gonzales
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Iakiv Kramarenko
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterprise
Marjan Nikolovski
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
Ying Zhang
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
Cornel Stefanache
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
icubesystem
 
Angular Mini-Challenges
Angular Mini-ChallengesAngular Mini-Challenges
Angular Mini-Challenges
Jose Mendez
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
Gabriele Falace
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
Iván Fernández Perea
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
IlPeach
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developersKai Koenig
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
Yakov Fain
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
Zoe Gilbert
 

What's hot (20)

Easy tests with Selenide and Easyb
Easy tests with Selenide and EasybEasy tests with Selenide and Easyb
Easy tests with Selenide and Easyb
 
Unit-testing and E2E testing in JS
Unit-testing and E2E testing in JSUnit-testing and E2E testing in JS
Unit-testing and E2E testing in JS
 
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design PatternsHow AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]Kiss PageObjects [01-2017]
Kiss PageObjects [01-2017]
 
Testing 101
Testing 101Testing 101
Testing 101
 
Mocking in Java with Mockito
Mocking in Java with MockitoMocking in Java with Mockito
Mocking in Java with Mockito
 
AngularJS introduction
AngularJS introductionAngularJS introduction
AngularJS introduction
 
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...
 
Built to last javascript for enterprise
Built to last   javascript for enterpriseBuilt to last   javascript for enterprise
Built to last javascript for enterprise
 
Mockito with a hint of PowerMock
Mockito with a hint of PowerMockMockito with a hint of PowerMock
Mockito with a hint of PowerMock
 
AngularJS Basic Training
AngularJS Basic TrainingAngularJS Basic Training
AngularJS Basic Training
 
Asp.net mvc training
Asp.net mvc trainingAsp.net mvc training
Asp.net mvc training
 
Angular Mini-Challenges
Angular Mini-ChallengesAngular Mini-Challenges
Angular Mini-Challenges
 
AngularJS application architecture
AngularJS application architectureAngularJS application architecture
AngularJS application architecture
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
PHP Unit Testing in Yii
PHP Unit Testing in YiiPHP Unit Testing in Yii
PHP Unit Testing in Yii
 
AngularJS for designers and developers
AngularJS for designers and developersAngularJS for designers and developers
AngularJS for designers and developers
 
Overview of the AngularJS framework
Overview of the AngularJS framework Overview of the AngularJS framework
Overview of the AngularJS framework
 
Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium  Page Object Model and Implementation in Selenium
Page Object Model and Implementation in Selenium
 

Similar to Frontend training

Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Flutter Agency
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Iakiv Kramarenko
 
Unit test documentation
Unit test documentationUnit test documentation
Unit test documentation
Anjan Debnath
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
SpringPeople
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
Jeff Durta
 
mean stack
mean stackmean stack
mean stack
michaelaaron25322
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
Knoldus Inc.
 
Java script best practices v4
Java script best practices v4Java script best practices v4
Java script best practices v4
Thor Jørund Nydal
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
GlobalLogic Ukraine
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testabilitydrewz lin
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
Abhijeet Vaikar
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
Mike Nakhimovich
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
Knoldus Inc.
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
pleeps
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testingdrewz lin
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
kaven yan
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
Alessandro Giorgetti
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
Yakov Fain
 

Similar to Frontend training (20)

Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...
 
Unit test documentation
Unit test documentationUnit test documentation
Unit test documentation
 
Unit testing basic
Unit testing basicUnit testing basic
Unit testing basic
 
Mastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium SuccessfullyMastering Test Automation: How To Use Selenium Successfully
Mastering Test Automation: How To Use Selenium Successfully
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
mean stack
mean stackmean stack
mean stack
 
Unit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJSUnit Testing and Coverage for AngularJS
Unit Testing and Coverage for AngularJS
 
Java script best practices v4
Java script best practices v4Java script best practices v4
Java script best practices v4
 
Angular 2 in-1
Angular 2 in-1 Angular 2 in-1
Angular 2 in-1
 
谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability谷歌 Scott-lessons learned in testability
谷歌 Scott-lessons learned in testability
 
Good practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium testsGood practices for debugging Selenium and Appium tests
Good practices for debugging Selenium and Appium tests
 
Advanced Dagger talk from 360andev
Advanced Dagger talk from 360andevAdvanced Dagger talk from 360andev
Advanced Dagger talk from 360andev
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
 
Grails unit testing
Grails unit testingGrails unit testing
Grails unit testing
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Top100summit 谷歌-scott-improve your automated web application testing
Top100summit  谷歌-scott-improve your automated web application testingTop100summit  谷歌-scott-improve your automated web application testing
Top100summit 谷歌-scott-improve your automated web application testing
 
The Theory Of The Dom
The Theory Of The DomThe Theory Of The Dom
The Theory Of The Dom
 
Angular Unit Testing
Angular Unit TestingAngular Unit Testing
Angular Unit Testing
 
Angular 2 for Java Developers
Angular 2 for Java DevelopersAngular 2 for Java Developers
Angular 2 for Java Developers
 

More from Adrian Caetano

Java script
Java scriptJava script
Java script
Adrian Caetano
 
Typescript
TypescriptTypescript
Typescript
Adrian Caetano
 
Web assembly
Web assemblyWeb assembly
Web assembly
Adrian Caetano
 
Electron
ElectronElectron
Electron
Adrian Caetano
 
Protobuff
ProtobuffProtobuff
Protobuff
Adrian Caetano
 
Workers
WorkersWorkers
Puppeteer
PuppeteerPuppeteer
Puppeteer
Adrian Caetano
 
Bff and GraphQL
Bff and GraphQLBff and GraphQL
Bff and GraphQL
Adrian Caetano
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
Adrian Caetano
 

More from Adrian Caetano (9)

Java script
Java scriptJava script
Java script
 
Typescript
TypescriptTypescript
Typescript
 
Web assembly
Web assemblyWeb assembly
Web assembly
 
Electron
ElectronElectron
Electron
 
Protobuff
ProtobuffProtobuff
Protobuff
 
Workers
WorkersWorkers
Workers
 
Puppeteer
PuppeteerPuppeteer
Puppeteer
 
Bff and GraphQL
Bff and GraphQLBff and GraphQL
Bff and GraphQL
 
Treinamento frontend
Treinamento frontendTreinamento frontend
Treinamento frontend
 

Recently uploaded

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
Globus
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Globus
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Globus
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
WSO2
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Globus
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
Donna Lenk
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
Globus
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
Globus
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
Srikant77
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
Juraj Vysvader
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
vrstrong314
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus
 

Recently uploaded (20)

AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024Globus Compute Introduction - GlobusWorld 2024
Globus Compute Introduction - GlobusWorld 2024
 
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...
 
Accelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with PlatformlessAccelerate Enterprise Software Engineering with Platformless
Accelerate Enterprise Software Engineering with Platformless
 
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisProviding Globus Services to Users of JASMIN for Environmental Data Analysis
Providing Globus Services to Users of JASMIN for Environmental Data Analysis
 
Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"Navigating the Metaverse: A Journey into Virtual Evolution"
Navigating the Metaverse: A Journey into Virtual Evolution"
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
How to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good PracticesHow to Position Your Globus Data Portal for Success Ten Good Practices
How to Position Your Globus Data Portal for Success Ten Good Practices
 
Enhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdfEnhancing Research Orchestration Capabilities at ORNL.pdf
Enhancing Research Orchestration Capabilities at ORNL.pdf
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
RISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent EnterpriseRISE with SAP and Journey to the Intelligent Enterprise
RISE with SAP and Journey to the Intelligent Enterprise
 
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...
 
top nidhi software solution freedownload
top nidhi software solution freedownloadtop nidhi software solution freedownload
top nidhi software solution freedownload
 
Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024Globus Connect Server Deep Dive - GlobusWorld 2024
Globus Connect Server Deep Dive - GlobusWorld 2024
 

Frontend training

  • 2. Goals ❏ Help the team: ❏ To take better decisions in frontend architecture ❏ To think about frontend design code ❏ Setup tests ❏ To make better unit tests
  • 6. Layers Architecture Abstraction logic not related to UI State Management Async Services Service Layer Presentation Module A Presentation Module B Presentation/ View Layer
  • 7. Layers Architecture ❏ Isolated UI logic from others logic ❏ Easier to test ❏ Easier to maintain ❏ SOC ❏ Control the application state in a simple way - No NgRx (Angular Redux)
  • 8. Components Presentation Module Containers or Smart Components 1 … N Dumb components Dumb components Dumb components
  • 9. Smart components ❏ Services Injected ❏ Know how to get the data ❏ Pass data to the dumb components ❏ react to the events from dumb components ❏ Are top-level routable components (but not always!).
  • 10. Dumb/Presentational Components ❏ should not be dependant on external services ❏ Should be predictable - not produce any side effects ❏ Should not mutate its’ inputs — because if it does, it actually produces a side effect - a child should never directly edit parent’s data.
  • 12. Module ❏ An application is made up of several blocks, which are ngModules or modules. ❏ Give context for our components to run ❏ Correct use of modules has a positive impact on application performance through the use of Lazy Loading. ❏ Angular Modules: BrowserModule, CommonModule, HttpClientModule, RouterModule, FormsModule and ReactiveFormsModule
  • 13. Module Options ❏ Declarations - where we put our components, directives, pipes and masks - the things related with the module itself ❏ Imports - to import another modules with services, pipe, components and others resources. The dependencies necessary on the module ❏ Exports - public components, submodules, directives, etc to be used in others module ❏ entryComponents - components not linked with routes or bootstrap in app module - example: modals
  • 14. Architecture Modules ❏ Coreservices Module - All services that are singleton and global (interceptor, guards, ). - optional ❏ SharedModule - Shared components, directives, pipes, masks between the various application modules. ❏ Layout Module - Components that are the basis for the entire application (eg header, menu-aside, footer) ❏ FeatureModule - Module by Feature ❏ AppRoutingModule - Main Routing Module ❏ FeatureRoutingModule - sub-module of a feature ❏ CoreModule and LayoutModule can only be imported once
  • 17. When I get an US... ❏ Check the requirements and what is necessary to do ❏ See if the US is possible to be developed ❏ Create your own checklist ❏ Which module? ❏ Do I need to create components? ❏ Presentational component or smart component? Or both? ❏ What is UI logic and what is not? ❏ What kind of services do I need?
  • 18. Jest
  • 19. What is Jest is a delightful JavaScript Testing Framework with a focus on simplicity. It works with projects using: Babel, TypeScript, Node, React, Angular, Vue and more! Made on top of Jasmine
  • 20. Why to Use? ❏ Easy to config and setup tests in most projects ❏ Focuses on Developer Experience (speed and ease of use is the first priority.) ❏ Isolated and high performance to execute ❏ Tests run in parallel ❏ It has a really good documentation ❏ The API is richer than Jasmine ❏ rerun instantly only tests related to latest code changes ❏ Abstracting the DOM with jsdom library - don't use a headless browser
  • 23. Mock x Stub x Spy ❏ It is very rare that the units we are testing do not have dependencies ❏ "Test Double is a generic term for any case where you replace a production object for testing purposes". Martin Fowler
  • 24. Mock ❏ Mocks fake something - its a copy ❏ Avoid flaky testing not calling something with side effect - like HTTP requests ❏ Mock is the simplest way to fake something
  • 25. Mock import {LoginComponent} from './login.component'; class MockAuthService { authenticated = false; isAuthenticated() { return this.authenticated; } }
  • 26. Use Mock describe('Component: Login', () => { let component: LoginComponent; let service: MockAuthService; beforeEach(() => { (2) service = new MockAuthService(); component = new LoginComponent(service); }); afterEach(() => { service = null; component = null; }); it('canLogin returns false when the user is not authenticated', () => { service.authenticated = false; (3) expect(component.needsLogin()).toBeTruthy() ; }); it('canLogin returns false when the user is not authenticated', () => { service.authenticated = true; (3) expect(component.needsLogin()).toBeFalsy(); }); });
  • 27. Spy ❏ The main benefit of spies is that they allow to watch how the function is used. ❏ We use spies when we want to track: ❏ if a inside function has been called into another function, ❏ how many times it has been called, ❏ which arguments were passed.
  • 28. Spy describe('MyService', () => { let service; let someService; let spy; class SomeService { getValue = function() {}; } beforeEach(() => { someService = new SomeService(); service = new MyService(someService); }); it('#getValue should return value', () => { spy = jest.spyOn(someService, 'getValue'); spy.mockReturnValue('stub value'); expect(service.getValue()).toBe('stub value'); expect(spy).toHaveBeenCalled(); });
  • 29. Stub ❏ Its a spy evolution ❏ So a stub is a function that replaces a real implementation of an existing function. ❏ We use stubs if we want to: ❏ control individual method behavior for a specific test case, ❏ prevent a method from making side effects like communicating with the outside world using Angular's HttpClient. ❏ Checks our application behavior/response/outcome under certain scenarios ❏ In jest we use mockImplementation
  • 30. Service to stub @Injectable({ provideIn: 'root' }) export class LocalStorageWrapperService { constructor() { } private localStorage = localStorage; remove(key) { return this.localStorage.removeItem(key); } get(key) { try { return JSON.parse(this.localStorage.getItem(key)); } catch (e) { return null; } } set(key, value) { return localStorage.setItem(key, JSON.stringify(value));
  • 31. Stub @Injectable() export class LocalStorageWrapperStubService { constructor() { } private localStorage = new Map(); remove(key) { return this.localStorage.delete(key); } get(key) { try { return this.localStorage.get(key); } catch (e) { return null; } } set(key, value) { return this.localStorage.set(key, JSON.stringify(value)); }
  • 32. Jasmine x Jest❏ Unfriendly errors logs ❏ No code coverage include ❏ Runs tests runs sequentially ❏ Hard to run tests headless ❏ It’s already configured with Angular - more examples and code on the internet ❏ Great exceptions and logs when tests fail ❏ Code coverage without any additional setup ❏ Run tests in parallel ❏ Run 2.5x times faster than Jasmine ❏ Tests headless by default ❏ Has all jasmine matchers and include many more ❏ Has snapshot tests
  • 33. Jasmine x Jest❏ jasmine.createSpy() ❏ jasmine.createSpyObj('name', ['key']) ❏ jasmine.createSpy().and.retur nValue() ❏ spyOn(...).and.callFake(() => {}) ❏ jest.fn() ❏ jest.fn({key: jest.fn()} ❏ jest.fn().mockReturnValue(‘’) ❏ jest.spyOn(...).mockImplemen tation(() => {})
  • 35. TestBed ❏ Every component need to run with a context (module and dependencies) ❏ TestBed create the setup necessary to the component run describe('AppComponent', () => { beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ RouterTestingModule ], declarations: [ AppComponent ], }).compileComponents(); }));
  • 36. Use the testing modules library ❏ Instead of HttpClientModule use HttpClientTestingModule ❏ Instead of RouterModule use RouterTestingModule ❏ Instead of AnimationsModule use NoopAnimationsModule ❏ Always try to find a testing module to avoid side effects
  • 37. Unit Testing ❏ Testing one thing at a time, tests should not care about the points of interaction between different units of the application ❏ In Angular can be splitting into: ❏ Isolated - when we just test component functions. ❏ shallow unit tests - testing components template without rendering its children. It may be achieved by simply not registering child components inside of the TestBed function.
  • 39. Integration test ❏ Checking that multiples units are interacting with each other correctly ❏ Use: ❏ When the integration between components is needed for creating a meaningful test ❏ Testing DOM with a simple interaction involving multiple components ❏ When testing integrations with third-party libraries
  • 40. Snapshot ❏ It’s good for black box testing ❏ You can use snapshot tests based on some inputs ❏ Snapshots should be deterministic ❏ You can run multiple times the same test and won’t fail ❏ Use consistent values: Date.now = jest.fn(() => 1482363367071); ❏ You can use snapshots for: ❏ Templates HTML - Dumb components ❏ JavaScript Lists and Objects
  • 42. Snapshot - inline DOM it('Snapshot of html component=', () => { const fixture = TestBed.createComponent(AppComponent); const ulList = fixture.debugElement.nativeElement.querySelector('.ul- list'); expect(ulList).toMatchSnapshot('AppComponent ul-list'); });
  • 43.
  • 44. Jest x Jasmine ❏ Jasmine and Jest API it's not that different. ❏ If we know how to test in Angular we know how to test in Jest
  • 45. The unit test shoudn’t be hard
  • 47. Testing Module @NgModule({ declarations: [], imports: [ CommonModule, NoopAnimationsModule, HttpClientTestingModule, RouterTestingModule, ], // Tells the compiler not to error on unknown elements and attributes schemas: [NO_ERRORS_SCHEMA] providers: [ { provide: SystemSettingsService, useClass: SystemSettingsServiceStub }, { provide: LocalStorageWrapperService, useClass: LocalStorageWrapperServiceStub } ] })
  • 48. Using Testing Module describe('LoginComponent', () => { let component: LoginComponent; let fixture: ComponentFixture<LoginComponent>; beforeEach(async(() => { TestBed.configureTestingModule({ imports: [ AuthModule, TestingModule, ], }) .compileComponents(); }));
  • 49. Stick to black-box testing: Test only public methods
  • 50. Group your tests ❏ Group by type of tests (DOM tests, black box tests, integration tests, snapshot tests and component tests) ❏ Each group of test may have your own beforeEach - tests run faster
  • 51. Group your tests describe('DummyComponent.spec', () => { beforeEach(() => { // Setup Tests }) describe('DOM Tests', () => { it('Test Something', () => { // ... }) }) })
  • 52. Clear mocks beforeEach(() => { jest.clearAllMocks(); });
  • 53. What to test ❏ Navigation ❏ Set a guard and check if only logged users can access a route ❏ Something happened and then the navigation occurs ❏ 404 view ❏ If someone type something wrong on URL goes to login
  • 54. What to test? ❏ Services ❏ to HTTP requests use HTTPTestingModule and check if the URL is correct called, queryParams based on inputs, if the payload will be transform into a intance of something ❏ It's easy to test because you don't have the DOM ❏ That's why architecture matter - UI logic stay on component and the rest in services
  • 55. What to test? ❏ Component.ts ❏ Check if the component is running correctly ❏ Testing public methods ❏ If it has forms use reactive forms - easier to test ❏ Take snapshots ❏ List of objects ❏ Dumb components - DOM ❏ Any important logic. ex: data transformation to show on the UI
  • 56. What to test? ❏ DOM ❏ Rules - not ngIf itself, but the rule ❏ Use DebugElement ❏ How something appear in the view ❏ Use fixture.detectChanges() correctly it('should find the <p> with fixture.debugElement.nativeElement)', () => { const bannerDe: DebugElement = fixture.debugElement; const bannerEl: HTMLElement = bannerDe.nativeElement; const p = bannerEl.querySelector('p'); expect(p.textContent).toEqual('banner works!'); });
  • 57. Plus: One E2E smoke test it('When doing smoke testing over all page, should load them all successfully', () => { // exemplified using Cypress but can be implemented easily // using any E2E suite cy.visit('https://mysite.com/home'); cy.contains('Home'); cy.contains('https://mysite.com/Login'); cy.contains('Login'); cy.contains('https://mysite.com/About'); cy.contains('About'); })
  • 58. Plus2: Good Tests Examples https://codecraft.tv/courses/angular/unit-testing/overview/

Editor's Notes

  1. Where and when I create a component? Is this a service logic or should I put on component? Should I put on the child component or parent component How my components will interact? Where I import this? How can I create something from scratch? How do I structure my tests? How do I setup my tests? What to test?
  2. [E importante ter uma arquitetura que permita que o desenvolvimento escale, porque do contrario, sem investimento em arquitetura, cada vez fica mais dificil de adicionar novas features encima do que ja existe. A arquitetura descreve como um software e composto e quais regras e constrantes temos para a comunicacao entre essas partes. - O papel do arquiteto e quebrar as pedras maiores, mas isso não siginifica que o time não tenha que pensar em arquitetura tambem. Mesmo pequenas decisoes no desenvolvimento se forem ruins, com o tempo podem ficar cada vez mais dificil de ser alteradas tendo um impacto negativo na arquitetura da aplicacão.
  3. Abstract logic Salvar no storage Manipulação e transformação de dados helpers/utils methods
  4. A partir de um input ele renderiza de uma forma if it requires some data to work, it should be injected via @Input(); if it needs to emit something, it should be emitted with @Output() instead;
  5. botar aqui schemas, entryComponents, imports, declarations, exports e providers
  6. Falar que eles vão fazer isso depois e que eles podem desenhar isso em algum lugar
  7. Analisar o que precisa ser feito, preciso de service? preciso de componentes? quais? ja existe componente?
  8. Código
  9. Code example
  10. What is and when to use
  11. Code example
  12. Code example
  13. What is and when to use
  14. Code example
  15. Stub ta ligado a comportamento e mock ta mais ligado a estado da aplicacao, fazer uma copia de um estado da aplicacao afim de evitar que um servico ou dependencia seja chamada de forma quente
  16. Code example
  17. Code example
  18. Código
  19. jest.spyOn chama a função que ta com o spy
  20. Assim como precisamos de um modulo pra rodar o contexto do component, nos testes tambem precisamos, pra carregar as dependencias dos componentes - outros modulos, HTTP, services injetados, etc.
  21. Code example
  22. Nao sao testes E2E Basicamente sao testes que envolve multiplos components ou mais de uma camada como comunicar um componente com um servico
  23. ar, podemos por exemplo fazer um teste que busca um botao no DOM, clica nesse botao e chama um servico que armazena algo em um state da aplicacao ou um input de formulario que faz um botao aparecer. Integration tests nao vamos mockar tudo pra isolar o que queremos testar
  24. Falar que pra pesquisar se vocês pesquisarem teste em angular, vão achar o que precisam
  25. Use double tests correctly TestSide gera flaky testes
  26. Error schema - But the compiler won't throw an error when it encounters <app-banner>, <app-welcome>, or <router-outlet>. It simply renders them as empty tags and the browser ignores them. You no longer need the stub components. That`s why we need NO_ERRORS_SCHEMA
  27. A ordem dos import importa, porque as dependencias repetidas entre um e outro serão sobreescritas pelo ultimo import
  28. Não passem uma variavel ou metodo privado pra publico so por causa do teste. Eu ja fiz isso e isso gera esforco desnecessario, porque se eu tenho algo privado que ta sendo usado em um m[etodo publico eu testo esse metodo publico que e minha interface com outras coisas.
  29. https://codewithhugo.com/jest-stub-mock-spy-set-clear/ Limpar os mocks, resetar eles ao estado inicial, evitando que um spy de um possa interferir no outro e gerando flaky tests
  30. Falar sobre as listas de objetos quando forem manipuladas, tirar um snapshot dela
  31. Angular relies on the DebugElement abstraction to work safely across all supported platforms. Instead of creating an HTML element tree, Angular creates a DebugElement tree that wraps the native elements for the runtime platform. Mais estavel de testar
  32. É um e2e fácil de manter, garante que nada está quebrando, traz um alto valor e consegue detectar qualquer tipo de falha, funcional, network ou problemas de deploy
  33. É um e2e fácil de manter, garante que nada está quebrando, traz um alto valor e consegue detectar qualquer tipo de falha, funcional, network ou problemas de deploy
  34. É um e2e fácil de manter, garante que nada está quebrando, traz um alto valor e consegue detectar qualquer tipo de falha, funcional, network ou problemas de deploy