Repository navigation
Developer Guide
Manuel edited this page Jan 22, 2024
·
17 revisions
- JavaScript/TypeScript
- React
- FontAwesome
- Chart.js
- ESlint
- JavaScript/TypeScript
- Express
- Sqlite3
- JavaScript/TypeScript
- Cypress
- Cypress Image Snapshot
- Components that are intended to be used as reusable components should be named as
<Custom[ComponentName]>so a reusable Alert component should be namedCustomAlert. - We name component files the same as the components they represent with an
.jsxextension soCustomAlert.jsx.
- We name CSS files the same as the component they belong to so the CSS file for the
Todo.jsxcomponent would beTodo.css. - We name CSS classes using the BEM naming convention in the following manner:
-
.Componenent__inner-element: So that for theTodo.cssthe rule styling the delete button would be written as.Todo__delete-button.
-
- We name functions belonging to the API class (used to make requests to the backend API) <[action][modelName]> so:
getTodogetTodosaddTodoeditTododeleteTodo
- We name our database tables with singular and uppercase names:
TodoDailyLearning
- We name our database table fields camelcased:
date,title,locationName,imageUrl, etc.
-
We create folders for different routes and give them model names:
/users/todos/events
-
We name our routers
<[CRUD action of the router][modelName]Router>when importing them on server/app.js. A router to add a new user todo would be namedcreateTodoRouter. -
We names router files
<[CRUD action of the router][modelName]>.jsso:readTodo.jsreadTodos.jscreateTodo.jsupdateTodo.jsdeleteTodo.js
- We name endpoints
/api/[modelNameInPlural]/[:id] (in case id required)so for Learning models CRUD actions endpoints/api/learnings/:idwould be used.
- These tests include: api, end-to-end, functional, smoke, responsiveness, etc
- For UI tests we name test files
<[(functionality|component)to test].cy.js>so a test for Login functionality test file would belogin.cy.jsand a test for Post functionality would bepost.cy.js. - For UI test cases are named using the
"should do X when input Y"naming convention. So"should login user when entering valid credentials"for example.
-
For API tests we separate tests into CRUD actions. A test for Todo API endpoints would be:
-
create-todo.cy.js. -
read-todo.cy.js. -
update-todo.cy.js. -
delete-todo.cy.js.
-
-
For API tests cases are named
"<HTTP method> /api/<modelNameInPlural>/:id - should <CRUD action> a <modelName>". For Todo API test cases:"POST - /api/todos/:id - should create a todo when requesting with valid data""GET - /api/todos/ - should retrieve all existing todos""GET - /api/todos/:id - should retrieve a specific todo""PATCH - /api/todos/:id - should update a specific todo""DELETE - /api/todos/:id - should delete a specific todo"
- On functional tests do operations like login programmatically and stub and mock as many requests as possible in order to improve test performance.
- When all tests are implemented we should have the following folders for tests:
- API
- E2E
- Functional
- Responsiveness
- Smoke
- Integrate visual tests along the flow of responsiveness and smoke tests. Functional or component tests are too numerous and integrating visual tests there could hinder performance.
- Divide tests cases in Positive and Negative contexts.
- Really implements lots of component tests cases so the amount of functional e2e and smoke test cases is lower.
- When mentioning(in requirements/test cases) that a form allows a user to login or register or in general submit with valid data then whatever valid data is should be defined somewhere:
- Valid username: (min 4 alphanumeric chars/max 20 alphanumeric chars).
- Do not use any hardcoded data in tests. Use fixtures.
- Add component tests inside the front-end folder.
- When testing on an input check that input value cannot:
- Be empty.
- Be shorter than expected(if alpha chars expected).
- Be longer than expected(if alpha chars expected).
- Be minus(if numeric chars expected)
- Be 0(in case this makes sense like when choosing a product quantity).
- Be higher than expected(in case this makes sense like choosing product amount then 9.999.999 should not be a possibility).