The document discusses frontend architecture and Jest testing. It covers goals of helping the team with architecture decisions, setup tests, and better unit tests. It then covers layers architecture with modules, components, services, and binding. It introduces Jest as a JavaScript testing framework and covers mocks, spies, stubs, and differences from Jasmine. It provides examples of unit testing Angular components in Jest with TestBed and avoiding side effects.
Unit testing helps improving the quality of your code and greatly simplifies dealing with complex code. The testing framework of choice for React.js is Jest.
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
This presentation is one of the best presentations from our study material for our JavaScript Object Oriented workshops which ADMEC conducts every week at the
center.
Unit testing helps improving the quality of your code and greatly simplifies dealing with complex code. The testing framework of choice for React.js is Jest.
MVC Design Pattern in JavaScript by ADMEC Multimedia InstituteRavi Bhadauria
This presentation is one of the best presentations from our study material for our JavaScript Object Oriented workshops which ADMEC conducts every week at the
center.
Selenide is simple and powerful in use wrapper-library over Selenium. But what the point just of shorter lines of code? In this talk we will see how to tame your webui mustang with Selenide and put it into fence of simple BDD stories with Easyb. We also consider pros and cons of the approach and compare to available alternatives.
This talk was given at "The KISS Method and PageObjects" meetup (https://goo.gl/2DBuxj).
The talk is about KISS (Keep It Simple Stupid) principle applied to PageObjects design with a comparison to other more classic approaches.
The slides contain both Selenium Webdriver and Selenide examples.
src code for the talk: https://github.com/yashaka/talks/tree/master/kiss-pageobjects
DD. BDD. Unit. Mocking. Doubles. Fixtures. What does it all mean? These are terms which can strike fear into the most hardened developer. I want to show you that it's not that scary and how testing can save you time, money and headaches.
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Iakiv Kramarenko
Talk given on SeleniumCamp 2016 about:
- Main Selenide Features from Implementation point of view
- Examples of porting these features to python (using simplified Selene sources)
This talk can be considered as a HOWTO on porting Selenide to any language, if the following programming paradigms are considered as tools: Procedural, Modular, OOP.
Demonstrate some great aspects of Mockito. Made for Mockito v1.8.5.
All examples can be found @
https://github.com/dodozhang21/MockitoExamples
Ying Zhang (Dodo) http://pure-essence.net
AngularJs Mini-Challenges is a growing collection of “Challenges” about the most quirky parts of the AngularJs framework. It encourage you to find and fix common mistakes and subtle bugs, as well as performance issues and bad practices, that non-expert AngularJs programmers may encounter on their endeavours into the depths of the framework.
AngularJs Mini-Challenges does not aim to teach you AngularJs. Former knowledge of the Framework is strongly recommended in order to understand the topics covered in this Challenges.
Page Object Model and Implementation in Selenium Zoe Gilbert
There are various frameworks that have been used by the IT industry for robust, easy maintenance, and to automate their applications to make them flexible and reusable. Page Object Model is one of the frameworks that have been covered here in this blog step by step clearly to help you understand.
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
***VIDEO***: view in SD at http://youtu.be/HPHKeBakulQ or download in HD at http://bit.ly/1nyvA67
Often we have lack of automation resources. If we just would involve less experienced juniors to implement test model and even Manual QA to write DSL like tests…
In this talk I want to present the simplified approach to write PageObjects for your test model as it would be like playing “three chords” song on a guitar. And also share the experience of pacifying the LoadableComponent pattern, rather hard in implementation but making your tests much more DRY and easy to use in context of loading pages.
Selenide is simple and powerful in use wrapper-library over Selenium. But what the point just of shorter lines of code? In this talk we will see how to tame your webui mustang with Selenide and put it into fence of simple BDD stories with Easyb. We also consider pros and cons of the approach and compare to available alternatives.
This talk was given at "The KISS Method and PageObjects" meetup (https://goo.gl/2DBuxj).
The talk is about KISS (Keep It Simple Stupid) principle applied to PageObjects design with a comparison to other more classic approaches.
The slides contain both Selenium Webdriver and Selenide examples.
src code for the talk: https://github.com/yashaka/talks/tree/master/kiss-pageobjects
DD. BDD. Unit. Mocking. Doubles. Fixtures. What does it all mean? These are terms which can strike fear into the most hardened developer. I want to show you that it's not that scary and how testing can save you time, money and headaches.
Selenide Alternative in Practice - Implementation & Lessons learned [Selenium...Iakiv Kramarenko
Talk given on SeleniumCamp 2016 about:
- Main Selenide Features from Implementation point of view
- Examples of porting these features to python (using simplified Selene sources)
This talk can be considered as a HOWTO on porting Selenide to any language, if the following programming paradigms are considered as tools: Procedural, Modular, OOP.
Demonstrate some great aspects of Mockito. Made for Mockito v1.8.5.
All examples can be found @
https://github.com/dodozhang21/MockitoExamples
Ying Zhang (Dodo) http://pure-essence.net
AngularJs Mini-Challenges is a growing collection of “Challenges” about the most quirky parts of the AngularJs framework. It encourage you to find and fix common mistakes and subtle bugs, as well as performance issues and bad practices, that non-expert AngularJs programmers may encounter on their endeavours into the depths of the framework.
AngularJs Mini-Challenges does not aim to teach you AngularJs. Former knowledge of the Framework is strongly recommended in order to understand the topics covered in this Challenges.
Page Object Model and Implementation in Selenium Zoe Gilbert
There are various frameworks that have been used by the IT industry for robust, easy maintenance, and to automate their applications to make them flexible and reusable. Page Object Model is one of the frameworks that have been covered here in this blog step by step clearly to help you understand.
Three Simple Chords of Alternative PageObjects and Hardcore of LoadableCompon...Iakiv Kramarenko
***VIDEO***: view in SD at http://youtu.be/HPHKeBakulQ or download in HD at http://bit.ly/1nyvA67
Often we have lack of automation resources. If we just would involve less experienced juniors to implement test model and even Manual QA to write DSL like tests…
In this talk I want to present the simplified approach to write PageObjects for your test model as it would be like playing “three chords” song on a guitar. And also share the experience of pacifying the LoadableComponent pattern, rather hard in implementation but making your tests much more DRY and easy to use in context of loading pages.
Mastering Test Automation: How To Use Selenium SuccessfullySpringPeople
In this slide, identify what to test and choose the best language for automation. Learn to write maintainable and reusable Selenium tests and add UI layout test as part of automation using Galen framework. This slide will also guide you in reporting structure by using external plugin's, an illustration covering cross browser testing (Running selenium grid with Docker) and explain Code repository (Git) and Jenkins CI tool.
Adding a modern twist to legacy web applicationsJeff Durta
Avoid misery of working with legacy code
We will see how you can add independent and isolated components to existing pages; pages that may be difficult to change
React and Flux allow you to make self-contained additions that handle their own data access/persistence
“Angular 2-in-1" is an attempt to show both theory+practice, cons & pros of technology, in single turn. As a result, each listener could make his own, conscious choice of tools for work and play.
This presentation by Rostyslav Siryk (Senior Software Engineer, Consultant, GlobalLogic Kharkiv) was delivered at GlobalLogic Kharkiv JS TechTalk on December 18, 2017.
Good practices for debugging Selenium and Appium testsAbhijeet Vaikar
We often come across situations when:
> We cannot figure out why our Selenium/Appium scripts fail during execution either locally or on CI.
> We need to debug scripts locally while writing them but find debugging painful and slow
Debugging the scripts is often the approach to fix them. What all different ways we can do it?
I shared about some of the good practices I have used for debugging Selenium and Appium scripts
In this session, we will introduce you to the concept of unit testing and how we can add new features to our application without breaking anything. We will see how we can add unit test cases for each of our components and the importance of it.
- How BFF and GraphQL can be used together
- Reliable architecture to supply data
- Flexible architecture in data layer
- Improve user experience using BFF and GraphQL
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
We describe the deployment and use of Globus Compute for remote computation. This content is aimed at researchers who wish to compute on remote resources using a unified programming interface, as well as system administrators who will deploy and operate Globus Compute services on their research computing infrastructure.
Innovating Inference - Remote Triggering of Large Language Models on HPC Clus...Globus
Large Language Models (LLMs) are currently the center of attention in the tech world, particularly for their potential to advance research. In this presentation, we'll explore a straightforward and effective method for quickly initiating inference runs on supercomputers using the vLLM tool with Globus Compute, specifically on the Polaris system at ALCF. We'll begin by briefly discussing the popularity and applications of LLMs in various fields. Following this, we will introduce the vLLM tool, and explain how it integrates with Globus Compute to efficiently manage LLM operations on Polaris. Attendees will learn the practical aspects of setting up and remotely triggering LLMs from local machines, focusing on ease of use and efficiency. This talk is ideal for researchers and practitioners looking to leverage the power of LLMs in their work, offering a clear guide to harnessing supercomputing resources for quick and effective LLM inference.
A Comprehensive Look at Generative AI in Retail App Testing.pdfkalichargn70th171
Traditional software testing methods are being challenged in retail, where customer expectations and technological advancements continually shape the landscape. Enter generative AI—a transformative subset of artificial intelligence technologies poised to revolutionize software testing.
In software engineering, the right architecture is essential for robust, scalable platforms. Wix has undergone a pivotal shift from event sourcing to a CRUD-based model for its microservices. This talk will chart the course of this pivotal journey.
Event sourcing, which records state changes as immutable events, provided robust auditing and "time travel" debugging for Wix Stores' microservices. Despite its benefits, the complexity it introduced in state management slowed development. Wix responded by adopting a simpler, unified CRUD model. This talk will explore the challenges of event sourcing and the advantages of Wix's new "CRUD on steroids" approach, which streamlines API integration and domain event management while preserving data integrity and system resilience.
Participants will gain valuable insights into Wix's strategies for ensuring atomicity in database updates and event production, as well as caching, materialization, and performance optimization techniques within a distributed system.
Join us to discover how Wix has mastered the art of balancing simplicity and extensibility, and learn how the re-adoption of the modest CRUD has turbocharged their development velocity, resilience, and scalability in a high-growth environment.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Accelerate Enterprise Software Engineering with PlatformlessWSO2
Key takeaways:
Challenges of building platforms and the benefits of platformless.
Key principles of platformless, including API-first, cloud-native middleware, platform engineering, and developer experience.
How Choreo enables the platformless experience.
How key concepts like application architecture, domain-driven design, zero trust, and cell-based architecture are inherently a part of Choreo.
Demo of an end-to-end app built and deployed on Choreo.
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
Unleash Unlimited Potential with One-Time Purchase
BoxLang is more than just a language; it's a community. By choosing a Visionary License, you're not just investing in your success, you're actively contributing to the ongoing development and support of BoxLang.
How to Position Your Globus Data Portal for Success Ten Good PracticesGlobus
Science gateways allow science and engineering communities to access shared data, software, computing services, and instruments. Science gateways have gained a lot of traction in the last twenty years, as evidenced by projects such as the Science Gateways Community Institute (SGCI) and the Center of Excellence on Science Gateways (SGX3) in the US, The Australian Research Data Commons (ARDC) and its platforms in Australia, and the projects around Virtual Research Environments in Europe. A few mature frameworks have evolved with their different strengths and foci and have been taken up by a larger community such as the Globus Data Portal, Hubzero, Tapis, and Galaxy. However, even when gateways are built on successful frameworks, they continue to face the challenges of ongoing maintenance costs and how to meet the ever-expanding needs of the community they serve with enhanced features. It is not uncommon that gateways with compelling use cases are nonetheless unable to get past the prototype phase and become a full production service, or if they do, they don't survive more than a couple of years. While there is no guaranteed pathway to success, it seems likely that for any gateway there is a need for a strong community and/or solid funding streams to create and sustain its success. With over twenty years of examples to draw from, this presentation goes into detail for ten factors common to successful and enduring gateways that effectively serve as best practices for any new or developing gateway.
Enhancing Research Orchestration Capabilities at ORNL.pdfGlobus
Cross-facility research orchestration comes with ever-changing constraints regarding the availability and suitability of various compute and data resources. In short, a flexible data and processing fabric is needed to enable the dynamic redirection of data and compute tasks throughout the lifecycle of an experiment. In this talk, we illustrate how we easily leveraged Globus services to instrument the ACE research testbed at the Oak Ridge Leadership Computing Facility with flexible data and task orchestration capabilities.
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I ...Juraj Vysvader
In 2015, I used to write extensions for Joomla, WordPress, phpBB3, etc and I didn't get rich from it but it did have 63K downloads (powered possible tens of thousands of websites).
top nidhi software solution freedownloadvrstrong314
This presentation emphasizes the importance of data security and legal compliance for Nidhi companies in India. It highlights how online Nidhi software solutions, like Vector Nidhi Software, offer advanced features tailored to these needs. Key aspects include encryption, access controls, and audit trails to ensure data security. The software complies with regulatory guidelines from the MCA and RBI and adheres to Nidhi Rules, 2014. With customizable, user-friendly interfaces and real-time features, these Nidhi software solutions enhance efficiency, support growth, and provide exceptional member services. The presentation concludes with contact information for further inquiries.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
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
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)
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?
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
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
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
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
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
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/
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?
[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.
Abstract logic
Salvar no storage
Manipulação e transformação de dados
helpers/utils methods
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;
botar aqui schemas, entryComponents, imports, declarations, exports e providers
Falar que eles vão fazer isso depois e que eles podem desenhar isso em algum lugar
Analisar o que precisa ser feito, preciso de service? preciso de componentes? quais? ja existe componente?
Código
Code example
What is and when to use
Code example
Code example
What is and when to use
Code example
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
Code example
Code example
Código
jest.spyOn chama a função que ta com o spy
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.
Code example
Nao sao testes E2E
Basicamente sao testes que envolve multiplos components ou mais de uma camada como comunicar um componente com um servico
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
Falar que pra pesquisar se vocês pesquisarem teste em angular, vão achar o que precisam
Use double tests correctly
TestSide gera flaky testes
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
A ordem dos import importa, porque as dependencias repetidas entre um e outro serão sobreescritas pelo ultimo import
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.
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
Falar sobre as listas de objetos quando forem manipuladas, tirar um snapshot dela
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
É 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
É 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
É 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