create-codeverse 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/ReadMe.MD +484 -0
- package/bin/cli.js +346 -0
- package/lib/apply/front.js +122 -0
- package/lib/apply/test.js +73 -0
- package/lib/copyTemplate.js +73 -0
- package/lib/desktop.js +65 -0
- package/lib/installDependencies.js +96 -0
- package/lib/openInEditor.js +14 -0
- package/lib/packageJson.js +33 -0
- package/lib/paths.js +4 -0
- package/lib/prompts.js +147 -0
- package/lib/runCommand.js +44 -0
- package/lib/secret.js +80 -0
- package/lib/templates.js +97 -0
- package/lib/validateProjectName.js +24 -0
- package/lib/versions.js +110 -0
- package/package.json +49 -6
- package/templates/codeskills.enc +0 -0
- package/templates/extras/test-componentes/ReadMe.MD +44 -0
- package/templates/extras/test-componentes/cypress/component/Login.cy.jsx +120 -0
- package/templates/extras/test-componentes/cypress/fixtures/example.json +5 -0
- package/templates/extras/test-componentes/cypress/support/commands.js +25 -0
- package/templates/extras/test-componentes/cypress/support/component-index.html +14 -0
- package/templates/extras/test-componentes/cypress/support/component.js +24 -0
- package/templates/extras/test-componentes/cypress.config.js +10 -0
- package/templates/extras/test-componentes/src/app/page.jsx +5 -0
- package/templates/extras/test-componentes/src/components/Login.jsx +47 -0
- package/templates/extras/test-dependencias/tests/nome-do-script.test.js +79 -0
- package/templates/front/.env.example +0 -0
- package/templates/front/ReadMe.MD +51 -0
- package/templates/front/_gitignore +42 -0
- package/templates/front/biome.json +42 -0
- package/templates/front/jsconfig.json +8 -0
- package/templates/front/next.config.mjs +11 -0
- package/templates/front/package.template.json +41 -0
- package/templates/front/public/fonts/gitkeep +0 -0
- package/templates/front/public/icons/gitkeep +0 -0
- package/templates/front/public/images/gitkeep +0 -0
- package/templates/front/public/media/gitkeep +0 -0
- package/templates/front/public/sounds/gitkeep +0 -0
- package/templates/front/src/app/favicon.ico +0 -0
- package/templates/front/src/app/globals.css +9 -0
- package/templates/front/src/app/layout.js +14 -0
- package/templates/front/src/app/nome-da-rota/nome-da-rota.module.css +0 -0
- package/templates/front/src/app/nome-da-rota/page.jsx +5 -0
- package/templates/front/src/app/page.jsx +39 -0
- package/templates/front/src/app/page.module.css +98 -0
- package/templates/front/src/components/Nome-do-componente.jsx +5 -0
- package/templates/front/src/components/Nome-do-componente.module.css +0 -0
- package/templates/integracao/ReadMe.MD +41 -0
- package/templates/integracao/cypress/e2e/meu-teste.cy.js +75 -0
- package/templates/integracao/cypress/fixtures/example.json +5 -0
- package/templates/integracao/cypress/support/commands.js +25 -0
- package/templates/integracao/cypress/support/e2e.js +17 -0
- package/templates/integracao/cypress.config.js +7 -0
- package/templates/integracao/package.template.json +38 -0
- package/templates/test/.env.example +0 -0
- package/templates/test/ReadMe.MD +49 -0
- package/templates/test/_gitignore +25 -0
- package/templates/test/jest.reporters.config.mjs +14 -0
- package/templates/test/package.template.json +42 -0
- package/templates/test/src/nome-do-seu-script.js +4 -0
- package/templates/test/tests/nome-do-script.test.js +40 -0
- package/templates/versions.json +84 -0
- package/README.md +0 -3
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import './globals.css';
|
|
2
|
+
|
|
3
|
+
export const metadata = {
|
|
4
|
+
title: 'FrontEnd - Codeverse',
|
|
5
|
+
description: 'Template do Codeverse',
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export default function RootLayout({ children }) {
|
|
9
|
+
return (
|
|
10
|
+
<html lang="pt-BR">
|
|
11
|
+
<body>{children}</body>
|
|
12
|
+
</html>
|
|
13
|
+
);
|
|
14
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import styles from './page.module.css';
|
|
2
|
+
|
|
3
|
+
export default function Home() {
|
|
4
|
+
return (
|
|
5
|
+
<main className={styles.container}>
|
|
6
|
+
<div className={styles.content}>
|
|
7
|
+
<h1 className={styles.title}>Codeverse</h1>
|
|
8
|
+
<p className={styles.subtitle}>Explore. Aprenda. Colabore.</p>
|
|
9
|
+
|
|
10
|
+
<a
|
|
11
|
+
href="https://codeverse.dev.br"
|
|
12
|
+
target="_blank"
|
|
13
|
+
rel="noopener noreferrer"
|
|
14
|
+
className={styles.cta}>
|
|
15
|
+
<svg
|
|
16
|
+
className={styles.ctaIcon}
|
|
17
|
+
viewBox="-11.5 -10.23174 23 20.46348"
|
|
18
|
+
width="25"
|
|
19
|
+
height="25"
|
|
20
|
+
aria-hidden="true">
|
|
21
|
+
<circle r="2.05" fill="currentColor" />
|
|
22
|
+
<g stroke="currentColor" strokeWidth="1" fill="none">
|
|
23
|
+
<ellipse rx="11" ry="4.2" />
|
|
24
|
+
<ellipse rx="11" ry="4.2" transform="rotate(60)" />
|
|
25
|
+
<ellipse rx="11" ry="4.2" transform="rotate(120)" />
|
|
26
|
+
</g>
|
|
27
|
+
</svg>
|
|
28
|
+
Ver material tutorial
|
|
29
|
+
</a>
|
|
30
|
+
|
|
31
|
+
<p className={styles.tagline}>Scaffolding oficial - Codeverse</p>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<footer className={styles.footer}>
|
|
35
|
+
<p className={styles.footerText}>Pouco pra quem vê..., muito pra quem aprende.</p>
|
|
36
|
+
</footer>
|
|
37
|
+
</main>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
.container {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
display: flex;
|
|
4
|
+
min-height: 100vh;
|
|
5
|
+
width: 100%;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: flex-start;
|
|
9
|
+
padding: 2rem 1.5rem;
|
|
10
|
+
background-image:
|
|
11
|
+
linear-gradient(to bottom, rgba(10, 15, 30, 0.35), rgba(10, 15, 30, 0.5)),
|
|
12
|
+
url('https://minio.codeverse.dev.br/mural/1785759396834-148tgv.jpeg');
|
|
13
|
+
background-size: cover;
|
|
14
|
+
background-position: center;
|
|
15
|
+
background-repeat: no-repeat;
|
|
16
|
+
font-family:
|
|
17
|
+
system-ui,
|
|
18
|
+
-apple-system,
|
|
19
|
+
BlinkMacSystemFont,
|
|
20
|
+
'Segoe UI',
|
|
21
|
+
Roboto,
|
|
22
|
+
sans-serif;
|
|
23
|
+
text-align: center;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.content {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
align-items: center;
|
|
30
|
+
margin: 15rem 0 0 0;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.title {
|
|
34
|
+
margin: 0;
|
|
35
|
+
background: linear-gradient(135deg, #a5b4fc 0%, #38bdf8 100%);
|
|
36
|
+
background-clip: text;
|
|
37
|
+
-webkit-background-clip: text;
|
|
38
|
+
-webkit-text-fill-color: transparent;
|
|
39
|
+
font-size: clamp(2.5rem, 6vw, 4.5rem);
|
|
40
|
+
font-weight: 800;
|
|
41
|
+
letter-spacing: -0.02em;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.subtitle {
|
|
45
|
+
margin-top: 0.25rem;
|
|
46
|
+
color: #cbd5e1;
|
|
47
|
+
font-size: clamp(1rem, 2.5vw, 1.4rem);
|
|
48
|
+
font-weight: 400;
|
|
49
|
+
letter-spacing: 0.15em;
|
|
50
|
+
text-transform: uppercase;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cta {
|
|
54
|
+
display: inline-flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: 0.6rem;
|
|
57
|
+
margin-top: 1rem;
|
|
58
|
+
border-radius: 999px;
|
|
59
|
+
padding: 0.85rem 2.25rem;
|
|
60
|
+
background: linear-gradient(135deg, #a5b4fc 0%, #38bdf8 100%);
|
|
61
|
+
color: #0a0f1e;
|
|
62
|
+
font-weight: 700;
|
|
63
|
+
text-decoration: none;
|
|
64
|
+
transition:
|
|
65
|
+
transform 0.2s ease,
|
|
66
|
+
box-shadow 0.2s ease;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.cta:hover {
|
|
70
|
+
box-shadow: 0 10px 30px rgba(56, 189, 248, 0.35);
|
|
71
|
+
transform: translateY(-2px);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.ctaIcon {
|
|
75
|
+
animation: spin 6s linear infinite;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@keyframes spin {
|
|
79
|
+
from {
|
|
80
|
+
transform: rotate(0deg);
|
|
81
|
+
}
|
|
82
|
+
to {
|
|
83
|
+
transform: rotate(360deg);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.tagline {
|
|
88
|
+
margin-top: 1rem;
|
|
89
|
+
color: #94a3b8;
|
|
90
|
+
font-size: 0.85rem;
|
|
91
|
+
letter-spacing: 0.1em;
|
|
92
|
+
text-transform: uppercase;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.footer {
|
|
96
|
+
color: rgba(148, 163, 184, 0.6);
|
|
97
|
+
font-size: 0.85rem;
|
|
98
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Projeto de Testes de Integração (E2E) — Cypress
|
|
2
|
+
|
|
3
|
+
Projeto criado com o `create-codeverse`: testes End-to-End com o Cypress. O Cypress abre um site
|
|
4
|
+
de verdade no navegador e interage com ele como um usuário faria.
|
|
5
|
+
|
|
6
|
+
## Como rodar os testes
|
|
7
|
+
|
|
8
|
+
| Passo | Comando |
|
|
9
|
+
|---|---|
|
|
10
|
+
| Deixar o site a ser testado rodando | por padrão, em [http://localhost:3000](http://localhost:3000) |
|
|
11
|
+
| Abrir o terminal do VS Code | `` Ctrl + ` `` |
|
|
12
|
+
| Abrir o Cypress | `npm test` |
|
|
13
|
+
| No Cypress | Escolha **E2E Testing**, depois um navegador, depois o teste `meu-teste.cy.js` |
|
|
14
|
+
|
|
15
|
+
Para testar outro endereço, troque o `baseUrl` em `cypress.config.js`.
|
|
16
|
+
|
|
17
|
+
## Scripts
|
|
18
|
+
|
|
19
|
+
| Comando | O que faz |
|
|
20
|
+
|---|---|
|
|
21
|
+
| `npm test` | Abre o Cypress |
|
|
22
|
+
| `npm run clean` | Apaga do PC as versões antigas do programa Cypress (cerca de 200 MB cada), mantendo só a usada neste projeto |
|
|
23
|
+
|
|
24
|
+
## Estrutura
|
|
25
|
+
|
|
26
|
+
| Pasta / arquivo | Para que serve |
|
|
27
|
+
|---|---|
|
|
28
|
+
| `cypress/e2e/meu-teste.cy.js` | Teste E2E, com um exemplo de cada tipo de verificação |
|
|
29
|
+
| `cypress/fixtures/` | Dados de exemplo para os testes |
|
|
30
|
+
| `cypress/support/` | Arquivos de apoio do Cypress (comandos personalizados) |
|
|
31
|
+
| `cypress.config.js` | Configuração do Cypress (`baseUrl`) |
|
|
32
|
+
|
|
33
|
+
Os seletores e textos de `meu-teste.cy.js` (ex.: `h1`, `'Texto do título'`) são exemplos: ajuste
|
|
34
|
+
para os elementos do site que você está testando.
|
|
35
|
+
|
|
36
|
+
## Para saber mais
|
|
37
|
+
|
|
38
|
+
| Assunto | Link |
|
|
39
|
+
|---|---|
|
|
40
|
+
| Cypress E2E | [docs.cypress.io](https://docs.cypress.io/app/end-to-end-testing/writing-your-first-end-to-end-test) |
|
|
41
|
+
| Material da CodeVerse | [codeverse.dev.br](https://codeverse.dev.br) |
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// Teste E2E (End-to-End): o Cypress abre o site de verdade no navegador e
|
|
2
|
+
// interage com ele, como um usuário faria.
|
|
3
|
+
// Ajuste os seletores (h1, input, button...) conforme os elementos desse site.
|
|
4
|
+
|
|
5
|
+
// Cada matcher aparece UMA vez neste arquivo, para os alunos verem todos os tipos.
|
|
6
|
+
describe('Meu teste E2E', () => {
|
|
7
|
+
// beforeEach: roda antes de cada it, abrindo o site do zero
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
cy.visit('/');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('endereço e título da página', () => {
|
|
13
|
+
// include: a URL atual contém um trecho
|
|
14
|
+
cy.url().should('include', 'https://');
|
|
15
|
+
|
|
16
|
+
// eq: o título da aba (tag <title>) é exatamente este
|
|
17
|
+
cy.title().should('eq', 'Título da página');
|
|
18
|
+
|
|
19
|
+
// location pathname: a rota atual é a raiz do site
|
|
20
|
+
cy.location('pathname').should('eq', '/');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('elementos da tela', () => {
|
|
24
|
+
// exist: o elemento existe no DOM
|
|
25
|
+
cy.get('h1').should('exist');
|
|
26
|
+
|
|
27
|
+
// not.exist: um elemento que não deve estar na página
|
|
28
|
+
cy.get('.mensagem-de-erro').should('not.exist');
|
|
29
|
+
|
|
30
|
+
// be.visible: o elemento está visível na tela
|
|
31
|
+
cy.get('h1').should('be.visible');
|
|
32
|
+
|
|
33
|
+
// have.text: texto exato do elemento
|
|
34
|
+
cy.get('h1').should('have.text', 'Texto do título');
|
|
35
|
+
|
|
36
|
+
// contain: o elemento contém um trecho de texto
|
|
37
|
+
cy.get('body').should('contain', 'Texto do título');
|
|
38
|
+
|
|
39
|
+
// have.length: quantidade de elementos encontrados
|
|
40
|
+
cy.get('a').should('have.length.greaterThan', 0);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('atributos e estilos', () => {
|
|
44
|
+
// have.attr: o elemento tem o atributo com este valor
|
|
45
|
+
cy.get('a').first().should('have.attr', 'href');
|
|
46
|
+
|
|
47
|
+
// have.class: o elemento tem esta classe CSS
|
|
48
|
+
cy.get('button').first().should('have.class', 'nome-da-classe');
|
|
49
|
+
|
|
50
|
+
// have.css: o elemento tem este valor de CSS (o navegador devolve em rgb)
|
|
51
|
+
cy.get('h1').should('have.css', 'color', 'rgb(0, 0, 0)');
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('formulário', () => {
|
|
55
|
+
// have.value: o valor digitado aparece no campo
|
|
56
|
+
cy.get('input').first().type('meu texto').should('have.value', 'meu texto');
|
|
57
|
+
|
|
58
|
+
// be.enabled: o botão pode ser clicado
|
|
59
|
+
cy.get('button').first().should('be.enabled');
|
|
60
|
+
|
|
61
|
+
// be.disabled: o botão está desabilitado
|
|
62
|
+
cy.get('button[disabled]').should('be.disabled');
|
|
63
|
+
|
|
64
|
+
// be.checked: a caixa de seleção fica marcada depois do check
|
|
65
|
+
cy.get('input[type="checkbox"]').first().check().should('be.checked');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('navegação ao clicar', () => {
|
|
69
|
+
// contains + click: acha o elemento pelo texto e clica nele
|
|
70
|
+
cy.contains('a', 'Texto do link').click();
|
|
71
|
+
|
|
72
|
+
// include: depois do clique, a URL mudou para a nova rota
|
|
73
|
+
cy.url().should('include', '/nome-da-rota');
|
|
74
|
+
});
|
|
75
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ***********************************************
|
|
2
|
+
// This example commands.js shows you how to
|
|
3
|
+
// create various custom commands and overwrite
|
|
4
|
+
// existing commands.
|
|
5
|
+
//
|
|
6
|
+
// For more comprehensive examples of custom
|
|
7
|
+
// commands please read more here:
|
|
8
|
+
// https://on.cypress.io/custom-commands
|
|
9
|
+
// ***********************************************
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
// -- This is a parent command --
|
|
13
|
+
// Cypress.Commands.add('login', (email, password) => { ... })
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// -- This is a child command --
|
|
17
|
+
// Cypress.Commands.add('drag', { prevSubject: 'element'}, (subject, options) => { ... })
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// -- This is a dual command --
|
|
21
|
+
// Cypress.Commands.add('dismiss', { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
// -- This will overwrite an existing command --
|
|
25
|
+
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/e2e.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "integracao-cypress",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Projeto template didático de testes de integração com Cypress.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"keywords": [
|
|
7
|
+
"javascript",
|
|
8
|
+
"cypress",
|
|
9
|
+
"testes",
|
|
10
|
+
"testes-de-integracao",
|
|
11
|
+
"e2e",
|
|
12
|
+
"testing",
|
|
13
|
+
"codeverse"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://codeverse.dev.br/",
|
|
16
|
+
"author": {
|
|
17
|
+
"name": "Marcello",
|
|
18
|
+
"url": "https://github.com/mapcarboni/"
|
|
19
|
+
},
|
|
20
|
+
"contributors": [
|
|
21
|
+
{
|
|
22
|
+
"name": "Marcello",
|
|
23
|
+
"url": "https://github.com/mapcarboni/"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"name": "Thiago",
|
|
27
|
+
"url": "https://github.com/thiago-rferreira/"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"engines": {
|
|
32
|
+
"node": ">=20"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"test": "cls && cypress open",
|
|
36
|
+
"clean": "cls && npx cypress cache prune && rem Apaga do PC as versões antigas do programa Cypress, cerca de 200 MB cada, e mantém só a usada neste projeto"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Projeto de Testes — Jest
|
|
2
|
+
|
|
3
|
+
Projeto criado com o `create-codeverse`: JavaScript (ES Modules) com o Jest, para testes unitários
|
|
4
|
+
(funções, classes e regras de negócio) e testes com dependências (mocks).
|
|
5
|
+
|
|
6
|
+
## Como rodar os testes
|
|
7
|
+
|
|
8
|
+
| Passo | Comando |
|
|
9
|
+
|---|---|
|
|
10
|
+
| Abrir o terminal do VS Code | `` Ctrl + ` `` |
|
|
11
|
+
| Rodar todos os testes | `npm test` |
|
|
12
|
+
| Gerar o relatório em JSON (com cobertura) | `npm run report` |
|
|
13
|
+
| Gerar e abrir o relatório em HTML | `npm run dashboard` |
|
|
14
|
+
|
|
15
|
+
## Scripts
|
|
16
|
+
|
|
17
|
+
| Comando | O que faz |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `npm test` | Limpa o terminal e roda todos os testes, um arquivo por vez, mostrando cada caso |
|
|
20
|
+
| `npm run report` | Roda os testes com cobertura e grava `coverage/relatorio.json` |
|
|
21
|
+
| `npm run dashboard` | Gera o relatório em `_html-report/index.html` e abre no navegador |
|
|
22
|
+
|
|
23
|
+
## Estrutura
|
|
24
|
+
|
|
25
|
+
| Pasta / arquivo | Para que serve |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `src/nome-do-seu-script.js` | Código a ser testado: troque pela sua função ou classe |
|
|
28
|
+
| `tests/nome-do-script.test.js` | Testes, com um exemplo de cada verificação (`toBe`, `toEqual`, `toContain`...) |
|
|
29
|
+
| `jest.reporters.config.mjs` | Configuração do relatório em HTML |
|
|
30
|
+
| `.env.example` | Modelo das variáveis de ambiente: copie para `.env` e preencha |
|
|
31
|
+
|
|
32
|
+
Se você escolheu **Dependências** no `create-codeverse`, o arquivo de testes também traz exemplos
|
|
33
|
+
de mocks com `jest.fn()` (`mockReturnValue`, `mockResolvedValue`, `toHaveBeenCalledWith`...) e o
|
|
34
|
+
projeto já vem com o `axios` instalado.
|
|
35
|
+
|
|
36
|
+
## Como escrever um teste
|
|
37
|
+
|
|
38
|
+
| Parte | Exemplo | O que faz |
|
|
39
|
+
|---|---|---|
|
|
40
|
+
| `describe` | `describe('soma', () => { ... })` | Agrupa os testes de um assunto |
|
|
41
|
+
| `it` | `it('soma dois números', () => { ... })` | Um caso de teste |
|
|
42
|
+
| `expect` | `expect(soma(1, 2)).toBe(3)` | Confere o resultado |
|
|
43
|
+
|
|
44
|
+
## Para saber mais
|
|
45
|
+
|
|
46
|
+
| Assunto | Link |
|
|
47
|
+
|---|---|
|
|
48
|
+
| Jest | [jestjs.io/docs](https://jestjs.io/docs/getting-started) |
|
|
49
|
+
| Material da CodeVerse | [codeverse.dev.br](https://codeverse.dev.br) |
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Dependências
|
|
2
|
+
node_modules/
|
|
3
|
+
|
|
4
|
+
# Relatórios e cobertura gerados pelos scripts de teste (npm run report / npm run dashboard)
|
|
5
|
+
coverage/
|
|
6
|
+
relatorio.json
|
|
7
|
+
_html-report/
|
|
8
|
+
|
|
9
|
+
# Logs
|
|
10
|
+
npm-debug.log*
|
|
11
|
+
*.log
|
|
12
|
+
|
|
13
|
+
# Variáveis de ambiente
|
|
14
|
+
.env
|
|
15
|
+
.env.local
|
|
16
|
+
!.env.example
|
|
17
|
+
|
|
18
|
+
# Editores / IDEs
|
|
19
|
+
.vscode/
|
|
20
|
+
.idea/
|
|
21
|
+
|
|
22
|
+
# Arquivos de sistema operacional
|
|
23
|
+
.DS_Store
|
|
24
|
+
Thumbs.db
|
|
25
|
+
Desktop.ini
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "jest-test",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Projeto template didático de testes unitários e de dependências com Jest.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "cls && node --experimental-vm-modules node_modules/jest/bin/jest.js --runInBand --verbose",
|
|
8
|
+
"report": "npm test -- --coverage --json --outputFile=coverage/relatorio.json",
|
|
9
|
+
"dashboard": "npm test -- --config jest.reporters.config.mjs"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"javascript",
|
|
13
|
+
"jest",
|
|
14
|
+
"testes",
|
|
15
|
+
"testes-unitarios",
|
|
16
|
+
"testes-de-dependencias",
|
|
17
|
+
"mock",
|
|
18
|
+
"testing",
|
|
19
|
+
"nodejs",
|
|
20
|
+
"codeverse"
|
|
21
|
+
],
|
|
22
|
+
"homepage": "https://codeverse.dev.br/",
|
|
23
|
+
"author": {
|
|
24
|
+
"name": "Marcello",
|
|
25
|
+
"url": "https://github.com/mapcarboni/"
|
|
26
|
+
},
|
|
27
|
+
"contributors": [
|
|
28
|
+
{
|
|
29
|
+
"name": "Marcello",
|
|
30
|
+
"url": "https://github.com/mapcarboni/"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "Thiago",
|
|
34
|
+
"url": "https://github.com/thiago-rferreira/"
|
|
35
|
+
}
|
|
36
|
+
],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"type": "module",
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=20"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { nomeDaFuncao } from '../src/nome-do-seu-script.js';
|
|
2
|
+
|
|
3
|
+
// describe() agrupa testes relacionados em um bloco
|
|
4
|
+
describe('nomeDaFuncao', () => {
|
|
5
|
+
// it(): cada um é UM caso de teste
|
|
6
|
+
it('deve fazer o que a função promete', () => {
|
|
7
|
+
// expect(valorRecebido).matcher(valorEsperado)
|
|
8
|
+
expect(nomeDaFuncao(1)).toBe(1);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
it('toBe() compara valores primitivos (número, string, boolean) por igualdade exata', () => {
|
|
12
|
+
expect(1 + 1).toBe(2);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('toEqual() compara objetos e arrays por atributos', () => {
|
|
16
|
+
expect({ nome: 'Ana' }).toEqual({ nome: 'Ana' });
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('toContain() verifica se um array ou string contém um item/trecho', () => {
|
|
20
|
+
expect([1, 2, 3]).toContain(2);
|
|
21
|
+
expect('JavaScript').toContain('Script');
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('toBeTruthy() verifica se o valor é "verdadeiro" (truthy)', () => {
|
|
25
|
+
expect(1).toBeTruthy();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('toBeFalsy() verifica se o valor é "falso" (falsy: 0, "", null, undefined, NaN, false)', () => {
|
|
29
|
+
expect(0).toBeFalsy();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('toHaveLength() verifica o tamanho (length) de um array ou string', () => {
|
|
33
|
+
expect([1, 2, 3]).toHaveLength(3);
|
|
34
|
+
expect('abc').toHaveLength(3);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('toBeCloseTo() compara números decimais evitando erros de ponto flutuante', () => {
|
|
38
|
+
expect(0.1 + 0.2).toBeCloseTo(0.3);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
{
|
|
2
|
+
"codeskills": {
|
|
3
|
+
"base": {
|
|
4
|
+
"dependencies": {
|
|
5
|
+
"@prisma/client": "6.19.3",
|
|
6
|
+
"bcryptjs": "3.0.3",
|
|
7
|
+
"jsonwebtoken": "9.0.3"
|
|
8
|
+
},
|
|
9
|
+
"devDependencies": {
|
|
10
|
+
"prisma": "6.19.3"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"front": {
|
|
15
|
+
"base": {
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"next": "16.4.6",
|
|
18
|
+
"react": "19.3.1",
|
|
19
|
+
"react-dom": "19.3.1"
|
|
20
|
+
},
|
|
21
|
+
"devDependencies": {
|
|
22
|
+
"@biomejs/biome": "2.6.8"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"compiler": {
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"babel-plugin-react-compiler": "1.0.0"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"antd": {
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"antd": "6.7.1"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"antdRegistry": {
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@ant-design/nextjs-registry": "1.3.0"
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"axios": {
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"axios": "1.21.1"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"lucide": {
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"lucide-react": "1.74.0"
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"tailwind": {
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@tailwindcss/postcss": "4.3.5",
|
|
53
|
+
"tailwindcss": "4.3.5"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
"toast": {
|
|
57
|
+
"dependencies": {
|
|
58
|
+
"react-hot-toast": "2.6.1"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"test": {
|
|
63
|
+
"jest": {
|
|
64
|
+
"base": {
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"jest": "30.5.2",
|
|
67
|
+
"jest-html-reporters": "3.1.7"
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"dependencias": {
|
|
71
|
+
"dependencies": {
|
|
72
|
+
"axios": "1.21.1"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"cypress": {
|
|
77
|
+
"base": {
|
|
78
|
+
"devDependencies": {
|
|
79
|
+
"cypress": "16.3.0"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
package/README.md
DELETED