## KJMP
## TESTING - Quality Assurance
---
### The Front End
---
```
React Testing Library
```
- React testing library is great for integration tests.
- It can render components, simulate user actions on that component, then test what is displayed on the DOM.
- It structures tests with the user in mind which can lead to good testing etiquite.
----
- Used with Mock Service Worker (MSW) to mock API communication and return a predefined result.


----

---
### The Back End
---
- Supertest and Tape
- Nock to mock API communication
---
### End-to-End
---
*Cypress*
Integrate into CircleCI

---
Questions around our dataorting out our database
---
## The problem ?
We wanted a way to tag experiences in our app.
For example if someone identified as #Queer #Black and Disabled.
We wanted a way to do this without having to make different columns and going through that INNER JOIN pain.
Our mentor Jack recommended Enum's which led us to the SET command as well.
---
## Enums and Sets
These are advanced DATA TYPES.
---
## Data types
If you remember, SQL requires us to specify what type of data we're going to use for each entry in advance, e.g. these ones we learned in DB week
*SERIAL
An auto-incrementing number. Useful for IDs where each new entry needs a unique value.*
*VARCHAR(255)
This is a variable-length string. The number in brackets specifies the maximum number of characters.*
*TEXT
A string of any length.*
*INTEGER
A whole number (like 20). No fractions allowed.*
There are also **advanced data types**, like ENUM and SET.
---
## ENUM
Short for enumeration. This is a computer science concept- enumeration is a list of values where you can select one. In SQL, we're forcing each entry to have choose a value from this list, like a drop-down menu
---

---
## SET
The SET data type is very similar to ENUM. The easiest way to explain set is to An enumeration allows you to select one item from a list of items. SET allows you to select multiple items. Literally, a set of options.
The usefulness of SET, though, can be thrown into question because you can do the same thing with database design. E.g. many to many relationships
Also don't mistake SET for \set. SET is a psql database command whereas \set is a psql command line meta-command.
[more info about the difference between SET and \set](https://dzone.com/articles/postgresqls-psql-set-vs-set)
---
# Arrays
- Postgres allows columns to be defined as arrays of variable length.
- The type of the array can be an inbuilt type, a user-defined type or an enumerated type.
---
```
Declaring array columns in tables:
CREATE TABLE rock_band
(
name text,
members text[]
)
```
---
```
INSERT INTO rock_band
VALUES
('Led Zeppelin',
'{"Page", "Plant", "Jones", "Bonham"}'
)
```
---
```
postgres=# select * from rock_band;
name | members
--------------+---------------------------
Led Zeppelin | {Page,Plant,Jones,Bonham}
(1 row)
```
---
```
select name from rock_band where 'Mason' = ANY(members);
name
------------
Pink Floyd
(1 row)
```
---
## CircleCI
----
Continuous Integration YAML file (.yaml, .yml)
----
### VM vs Containers

----
Thank you for listening!
https://mswjs.io/docs/getting-started/mocks/rest-api
{"metaMigratedAt":"2023-06-15T14:15:29.340Z","metaMigratedFrom":"Content","title":"Arrays","breaks":true,"contributors":"[{\"id\":\"ec8babd0-356b-4e48-8e86-0ced63dfbb1f\",\"add\":295,\"del\":129},{\"id\":\"54b20be6-da49-4378-a738-063e13100e14\",\"add\":801,\"del\":3},{\"id\":\"70e73067-10d2-4b79-a4af-53ace8d9813b\",\"add\":1272,\"del\":417},{\"id\":\"d3c4a004-0006-4da0-9ba0-d08adcc37a9d\",\"add\":1232,\"del\":0}]"}