create-codeverse 0.0.0-stage → 0.0.1
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/ReadMe.MD +457 -0
- package/bin/cli.js +280 -0
- package/lib/apply/front.js +122 -0
- package/lib/apply/test.js +67 -0
- package/lib/copyTemplate.js +73 -0
- package/lib/desktop.js +13 -0
- package/lib/installDependencies.js +37 -0
- package/lib/openInEditor.js +14 -0
- package/lib/packageJson.js +19 -0
- package/lib/paths.js +4 -0
- package/lib/prompts.js +68 -0
- package/lib/runCommand.js +40 -0
- package/lib/secret.js +80 -0
- package/lib/templates.js +79 -0
- package/lib/validateProjectName.js +24 -0
- package/lib/versions.js +50 -0
- package/package.json +46 -6
- package/templates/codeskills.enc +0 -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 +36 -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/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 +37 -0
- package/templates/test/.env.example +0 -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 +81 -0
- package/README.md +0 -3
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jest } from '@jest/globals';
|
|
2
|
+
import { nomeDaFuncao } from '../src/nome-do-seu-script.js';
|
|
3
|
+
|
|
4
|
+
// describe() agrupa testes relacionados em um bloco
|
|
5
|
+
describe('nomeDaFuncao', () => {
|
|
6
|
+
// it(): cada um é UM caso de teste
|
|
7
|
+
it('deve fazer o que a função promete', () => {
|
|
8
|
+
// expect(valorRecebido).matcher(valorEsperado)
|
|
9
|
+
expect(nomeDaFuncao(1)).toBe(1);
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('toBe() compara valores primitivos (número, string, boolean) por igualdade exata', () => {
|
|
13
|
+
expect(1 + 1).toBe(2);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
it('toEqual() compara objetos e arrays por atributos', () => {
|
|
17
|
+
expect({ nome: 'Ana' }).toEqual({ nome: 'Ana' });
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
it('toContain() verifica se um array ou string contém um item/trecho', () => {
|
|
21
|
+
expect([1, 2, 3]).toContain(2);
|
|
22
|
+
expect('JavaScript').toContain('Script');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('toBeTruthy() verifica se o valor é "verdadeiro" (truthy)', () => {
|
|
26
|
+
expect(1).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it('toBeFalsy() verifica se o valor é "falso" (falsy: 0, "", null, undefined, NaN, false)', () => {
|
|
30
|
+
expect(0).toBeFalsy();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('toHaveLength() verifica o tamanho (length) de um array ou string', () => {
|
|
34
|
+
expect([1, 2, 3]).toHaveLength(3);
|
|
35
|
+
expect('abc').toHaveLength(3);
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('toBeCloseTo() compara números decimais evitando erros de ponto flutuante', () => {
|
|
39
|
+
expect(0.1 + 0.2).toBeCloseTo(0.3);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Mocks: jest.fn() cria uma função falsa que substitui uma dependência
|
|
44
|
+
// externa (uma API via Axios, por exemplo) e ainda registra como foi chamada.
|
|
45
|
+
describe('Mocks com jest.fn()', () => {
|
|
46
|
+
it('mockReturnValue() define o valor que o mock retorna', () => {
|
|
47
|
+
const buscar = jest.fn().mockReturnValue(7);
|
|
48
|
+
expect(buscar()).toBe(7);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('mockResolvedValue() faz o mock retornar uma Promise resolvida', async () => {
|
|
52
|
+
const buscar = jest.fn().mockResolvedValue('ok');
|
|
53
|
+
await expect(buscar()).resolves.toBe('ok');
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('mockRejectedValue() faz o mock retornar uma Promise rejeitada', async () => {
|
|
57
|
+
const buscar = jest.fn().mockRejectedValue(new Error('API fora do ar'));
|
|
58
|
+
await expect(buscar()).rejects.toThrow('API fora do ar');
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('toHaveBeenCalled() verifica se o mock foi chamado ao menos uma vez', () => {
|
|
62
|
+
const buscar = jest.fn();
|
|
63
|
+
buscar();
|
|
64
|
+
expect(buscar).toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('toHaveBeenCalledTimes() verifica quantas vezes o mock foi chamado', () => {
|
|
68
|
+
const buscar = jest.fn();
|
|
69
|
+
buscar();
|
|
70
|
+
buscar();
|
|
71
|
+
expect(buscar).toHaveBeenCalledTimes(2);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('toHaveBeenCalledWith() verifica com quais argumentos o mock foi chamado', () => {
|
|
75
|
+
const buscar = jest.fn();
|
|
76
|
+
buscar('USD', 10);
|
|
77
|
+
expect(buscar).toHaveBeenCalledWith('USD', 10);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
This is a [Next.js](https://nextjs.org) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
First, run the development server:
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm run dev
|
|
9
|
+
# or
|
|
10
|
+
yarn dev
|
|
11
|
+
# or
|
|
12
|
+
pnpm dev
|
|
13
|
+
# or
|
|
14
|
+
bun dev
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
|
|
18
|
+
|
|
19
|
+
You can start editing the page by modifying `app/page.js`. The page auto-updates as you edit the file.
|
|
20
|
+
|
|
21
|
+
This project uses [`next/font`](https://nextjs.org/docs/app/building-your-application/optimizing/fonts) to automatically optimize and load [Geist](https://vercel.com/font), a new font family for Vercel.
|
|
22
|
+
|
|
23
|
+
## Learn More
|
|
24
|
+
|
|
25
|
+
To learn more about Next.js, take a look at the following resources:
|
|
26
|
+
|
|
27
|
+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
|
|
28
|
+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
|
|
29
|
+
|
|
30
|
+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js) - your feedback and contributions are welcome!
|
|
31
|
+
|
|
32
|
+
## Deploy on Vercel
|
|
33
|
+
|
|
34
|
+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
|
|
35
|
+
|
|
36
|
+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/app/building-your-application/deploying) for more details.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
|
2
|
+
|
|
3
|
+
# dependencies
|
|
4
|
+
/node_modules
|
|
5
|
+
/.pnp
|
|
6
|
+
.pnp.*
|
|
7
|
+
.yarn/*
|
|
8
|
+
!.yarn/patches
|
|
9
|
+
!.yarn/plugins
|
|
10
|
+
!.yarn/releases
|
|
11
|
+
!.yarn/versions
|
|
12
|
+
|
|
13
|
+
# testing
|
|
14
|
+
/coverage
|
|
15
|
+
|
|
16
|
+
# next.js
|
|
17
|
+
/.next/
|
|
18
|
+
/out/
|
|
19
|
+
|
|
20
|
+
# production
|
|
21
|
+
/build
|
|
22
|
+
|
|
23
|
+
# misc
|
|
24
|
+
.DS_Store
|
|
25
|
+
*.pem
|
|
26
|
+
|
|
27
|
+
# debug
|
|
28
|
+
npm-debug.log*
|
|
29
|
+
yarn-debug.log*
|
|
30
|
+
yarn-error.log*
|
|
31
|
+
.pnpm-debug.log*
|
|
32
|
+
|
|
33
|
+
# env files (can opt-in for committing if needed)
|
|
34
|
+
.env*
|
|
35
|
+
!.env.example
|
|
36
|
+
|
|
37
|
+
# vercel
|
|
38
|
+
.vercel
|
|
39
|
+
|
|
40
|
+
# typescript
|
|
41
|
+
*.tsbuildinfo
|
|
42
|
+
next-env.d.ts
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://biomejs.dev/schemas/2.5.15/schema.json",
|
|
3
|
+
"vcs": {
|
|
4
|
+
"enabled": true,
|
|
5
|
+
"clientKind": "git",
|
|
6
|
+
"useIgnoreFile": true
|
|
7
|
+
},
|
|
8
|
+
"files": {
|
|
9
|
+
"ignoreUnknown": true,
|
|
10
|
+
"includes": ["**", "!node_modules", "!.next", "!dist", "!build"]
|
|
11
|
+
},
|
|
12
|
+
"formatter": {
|
|
13
|
+
"enabled": true,
|
|
14
|
+
"indentStyle": "space",
|
|
15
|
+
"indentWidth": 4
|
|
16
|
+
},
|
|
17
|
+
"javascript": {
|
|
18
|
+
"formatter": {
|
|
19
|
+
"quoteStyle": "single"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"linter": {
|
|
23
|
+
"enabled": true,
|
|
24
|
+
"rules": {
|
|
25
|
+
"recommended": true,
|
|
26
|
+
"suspicious": {
|
|
27
|
+
"noUnknownAtRules": "off"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"domains": {
|
|
31
|
+
"next": "recommended",
|
|
32
|
+
"react": "recommended"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"assist": {
|
|
36
|
+
"actions": {
|
|
37
|
+
"source": {
|
|
38
|
+
"organizeImports": "on"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "npx-next",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Projeto template padrão didático de front-end com NextJS (App Router) e React.",
|
|
5
|
+
"private": true,
|
|
6
|
+
"keywords": [
|
|
7
|
+
"javascript",
|
|
8
|
+
"nextjs",
|
|
9
|
+
"next",
|
|
10
|
+
"react",
|
|
11
|
+
"app-router",
|
|
12
|
+
"front-end",
|
|
13
|
+
"frontend",
|
|
14
|
+
"biome",
|
|
15
|
+
"codeverse"
|
|
16
|
+
],
|
|
17
|
+
"homepage": "https://codeverse.dev.br/",
|
|
18
|
+
"author": {
|
|
19
|
+
"name": "Marcello",
|
|
20
|
+
"url": "https://github.com/mapcarboni/"
|
|
21
|
+
},
|
|
22
|
+
"contributors": [
|
|
23
|
+
{
|
|
24
|
+
"name": "Marcello",
|
|
25
|
+
"url": "https://github.com/mapcarboni/"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "Thiago",
|
|
29
|
+
"url": "https://github.com/thiago-rferreira/"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=20"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"dev": "cls && next dev",
|
|
38
|
+
"lint": "biome check",
|
|
39
|
+
"format": "biome format --write"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
@@ -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,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,37 @@
|
|
|
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
|
+
}
|
|
37
|
+
}
|
|
File without changes
|
|
@@ -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
|