Testing

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Testing

Spy
A spy lets us verify what functions were called, with what arguments, when, and how often.

Stub
A stub is an object that provides (canned) hardcoded values to method calls. It always returns
the same output regardless of the input.

Mock
A mock is similar to a stub, but the behaviour of the mocked interface can be changed
dynamically based on scenarios. It is also similar to a spy as it allows us to verify that a method
was called. However, the assertion is in the verify method in a mock. In a spy, the assertion is in
the test,

Testing ensures that the methods, functions and components of an application perform their
expected behavior.

Idea of Guarantee: since errors are visible, tests make you less guilty for modifying some
code. You can easily add new features or work on a refactor but you know that if a bug
appear it should be detected.
Improve implementations: it enforce you to think and re-think the design of a solution
with the confidence that you are not adding any bugs.

CI/CD are tools to help a team to automate development, testing and deployment of an
application. is a method to frequently deliver apps to customers by introducing automation into
the stages of app development.

CI is an automation process for developers, it means that the new implemented changes are
frequently integrated in a shared branch of a repo. It helps to find conflicts earlier. Do not wait
for release day, and avoid integration hell. Once merged, they are build and unit and integration
testing.

CD means that the changes of a developer are tested and pushed to a repo from which can be
deployed. The goal is to simplify the deploy process. And having a codebase that is always in a
state that can de deployed.
Unit Testing is a software development process in which the correct operation is tested,
individually and independently of the smallest units of an app, a method or function.
Code behavior is analyzed.
It is a guarantee against changes that introduce bugs, and makes developers feel less guilty for
changes in the code and makes deficiencies in design visible.

Debugging
Is Searching and fixing syntax errors, or logical errors in programming code. Many of them are
difficult to locate or diagnose.

Debuggers: all modern browsers have a debugger that allow us to set breakpoints (to stop
code executions), allowing to examine variables.

Integration test: ensures that multiple components behave correctly together.


Acceptance test: similar to integration tests but focused on business cases rather than
components.
Test Runner: run the tests and summarize the results. ex: mocha
Library for assertions: define test logics, conditions. ex: chai
Headless Browser: simulate interaction with the browser.

Jasmine - Framework de testing, Behavior-Driven JS


Jasmine is a BDD (behavior-driven development) framework for testing JavaScript code.

The describe function is for grouping related specs (suite), typically each test file has one at
the top level.

Specs are defined by calling the global Jasmine function it, which, like describe takes a string
and a function. The string is the title of the spec and the function is the spec, or test. A spec
contains one or more expectations that test the state of the code.

An expectation in Jasmine is an assertion that is either true or false. A spec with all true
expectations is a passing spec. A spec with one or more false expectations is a failing spec.

¿Qué es Karma?
Karma es el test-runner, es decir, el módulo que permite automatizar algunas de las tareas de
las suites de testing, como Jasmine. Karm

Suite: describe es función para agrupar specs relacionados.

Spec: it es función que contiene una o varias expectativas (true o false) para testear el estado
del código. Todas son true el spec pasa, sino falla. Las expectativas se escriben con la función
expect que toma un valor real, y se encadena con una función matcher que toma el valor
esperado.

beforeEach es una función que se llama una vez antes de cada spec dentro del describe y
afterEach después de cada spec.

beforeAll se llama sólo una vez antes de todos los specs, y afterAll después de que todos
terminaron.

You might also like