Skip to content

Commit d803dfc

Browse files
feat: CI/CD improvements + translations
- Translate entire test suite from Portuguese to English - Update GitHub Actions with Node.js 22.x and coverage upload - Add test:watch script and update dependencies - Improve README documentation and structure
1 parent 8f1e9aa commit d803dfc

18 files changed

Lines changed: 151 additions & 112 deletions
Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
11
name: Node Test Runner
2+
23
on:
34
push:
45
branches: [ main, master ]
56
pull_request:
67
branches: [ main, master ]
78
schedule:
8-
- cron: '0 */12 * * *'
9+
- cron: '0 0 * * 0' # Every Sunday at midnight
10+
11+
permissions:
12+
contents: read
13+
914
jobs:
10-
build:
15+
test:
1116
runs-on: ubuntu-latest
17+
timeout-minutes: 10
1218

1319
strategy:
1420
matrix:
15-
node-version: [20.x]
16-
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
node-version: [22.x]
1722

1823
steps:
1924
- name: Checkout repository
2025
uses: actions/checkout@v4
26+
2127
- name: Use Node.js ${{ matrix.node-version }}
2228
uses: actions/setup-node@v4
2329
with:
2430
node-version: ${{ matrix.node-version }}
2531
cache: 'npm'
32+
2633
- name: Install dependencies
2734
run: npm ci
28-
- name: Run tests
29-
###run: npm test
35+
36+
- name: Run Node.js native tests
37+
run: npm test
38+
39+
- name: Upload Coverage Results
40+
if: always()
41+
uses: actions/upload-artifact@v4
42+
with:
43+
name: node-test-coverage
44+
path: coverage/ # Caso você use a flag --experimental-test-coverage
45+
retention-days: 30

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
# Dependencies
2+
node_modules/

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@ Example project for automated tests using **Node Test Runner** and **Gerador BR*
44

55
## Setup
66

7-
**Prerequisites:**
7+
## Prerequisites
88

99
* [Node.js](https://nodejs.org/) (includes npm)
1010

11-
**Installation:**
11+
## Installation
1212

13-
1. Clone this repository.
14-
2. Open your terminal in the project's root folder.
15-
3. Run the command to install dependencies:
13+
1. Clone this repository
14+
2. Install dependencies:
1615

1716
```bash
1817
npm install
1918
```
2019

21-
## Running the Tests
20+
## Running Tests
2221

2322
To execute the tests, use the following command:
2423

@@ -37,5 +36,5 @@ Test files are located in the `test` folder.
3736
The tests use data generated by Gerador-BR to validate forms or business logic with realistic Brazilian data.
3837

3938
## Documentation
40-
41-
* [Gerador-BR Documentation](https://box4.dev/gerador-br/)
39+
* [Node Test Runner](https://nodejs.org/api/test.html)
40+
* [Gerador-BR documentation](https://box4.dev/gerador-br/documentacao/?utm_source=github&utm_medium=node_data_generator)

package-lock.json

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@
44
"description": "Example of using Node Test Runner with the Gerador-BR data generator",
55
"type":"module",
66
"scripts": {
7-
"test": "node --test test"
7+
"test": "node --test",
8+
"test:watch": "node --test --watch"
89
},
910
"devDependencies": {
10-
"gerador-br": "^1.2.3"
11+
"gerador-br": "latest"
1112
},
1213
"keywords": [
1314
"node",

test/cartao-credito.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test';
22
import { strictEqual } from 'node:assert';
33
import { cartaoCredito } from 'gerador-br';
44

5-
describe('Cartão de Crédito Generator', () => {
5+
describe('Credit Card Generator', () => {
66
test('should generate a valid credit card number without mask', () => {
77
const creditCardData = cartaoCredito(false);
88
strictEqual(typeof creditCardData.numero, 'string');
@@ -12,7 +12,7 @@ describe('Cartão de Crédito Generator', () => {
1212
test('should generate a valid credit card number with mask', () => {
1313
const creditCardData = cartaoCredito(true);
1414
strictEqual(typeof creditCardData.numero, 'string');
15-
strictEqual(creditCardData.numero.length, 19); // formato: xxxx xxxx xxxx xxxx
15+
strictEqual(creditCardData.numero.length, 19); // format: xxxx xxxx xxxx xxxx
1616
strictEqual(creditCardData.numero.split(' ').length, 4);
1717
});
1818

test/certidao.test.js

Lines changed: 46 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2,85 +2,85 @@ import { describe, test } from 'node:test';
22
import { match, strictEqual } from 'node:assert';
33
import { certidao } from 'gerador-br';
44

5-
describe('certidao.js', () => {
6-
test('Geração de número de certidão de nascimento com máscara', () => {
5+
describe('Certificate Generator', () => {
6+
test('Generate birth certificate number with mask', () => {
77
const result = certidao.nascimento(true);
8-
// Verifica a máscara do número de certidão
9-
match(result, /^\d{6} \d{2} \d{4} 1001 \d \d{5} \d{3} \d{7}$/, 'A máscara da certidão de nascimento está incorreta');
8+
// Checks the certificate number mask
9+
match(result, /^\d{6} \d{2} \d{4} 1001 \d \d{5} \d{3} \d{7}$/, 'Birth certificate mask is incorrect');
1010
});
1111

12-
test('Geração de número de certidão de nascimento sem máscara', () => {
12+
test('Generate birth certificate number without mask', () => {
1313
const result = certidao.nascimento(false);
14-
// Verifica a ausência da máscara no número de certidão
15-
match(result, /^\d{32}$/, 'O número de certidão de nascimento sem máscara deve ter 32 dígitos');
14+
// Checks the absence of mask in the certificate number
15+
match(result, /^\d{32}$/, 'Birth certificate number without mask must have 32 digits');
1616
});
1717

18-
test('Geração de número de certidão de casamento com máscara', () => {
18+
test('Generate marriage certificate number with mask', () => {
1919
const result = certidao.casamento(true);
20-
// Verifica a máscara do número de certidão
21-
match(result, /^\d{6} \d{2} \d{4} 2001 \d \d{5} \d{3} \d{7}$/, 'A máscara da certidão de casamento está incorreta');
20+
// Checks the certificate number mask
21+
match(result, /^\d{6} \d{2} \d{4} 2001 \d \d{5} \d{3} \d{7}$/, 'Marriage certificate mask is incorrect');
2222
});
2323

24-
test('Geração de número de certidão de casamento sem máscara', () => {
24+
test('Generate marriage certificate number without mask', () => {
2525
const result = certidao.casamento(false);
26-
// Verifica a ausência da máscara no número de certidão
27-
match(result, /^\d{32}$/, 'O número de certidão de casamento sem máscara deve ter 32 dígitos');
26+
// Checks the absence of mask in the certificate number
27+
match(result, /^\d{32}$/, 'Marriage certificate number without mask must have 32 digits');
2828
});
2929

30-
test('Geração de número de certidão de óbito com máscara', () => {
30+
test('Generate death certificate number with mask', () => {
3131
const result = certidao.obito(true);
32-
// Verifica a máscara do número de certidão
33-
match(result, /^\d{6} \d{2} \d{4} 3001 \d \d{5} \d{3} \d{7}$/, 'A máscara da certidão de óbito está incorreta');
32+
// Checks the certificate number mask
33+
match(result, /^\d{6} \d{2} \d{4} 3001 \d \d{5} \d{3} \d{7}$/, 'Death certificate mask is incorrect');
3434
});
3535

36-
test('Geração de número de certidão de óbito sem máscara', () => {
36+
test('Generate death certificate number without mask', () => {
3737
const result = certidao.obito(false);
38-
// Verifica a ausência da máscara no número de certidão
39-
match(result, /^\d{32}$/, 'O número de certidão de óbito sem máscara deve ter 32 dígitos');
38+
// Checks the absence of mask in the certificate number
39+
match(result, /^\d{32}$/, 'Death certificate number without mask must have 32 digits');
4040
});
4141

42-
test('Geração de objeto detalhado para certidão de nascimento', () => {
42+
test('Generate detailed object for birth certificate', () => {
4343
const result = certidao.nascimentoObj();
44-
strictEqual(result.tipoCertidao, 'Nascimento', 'Tipo da certidão deve ser "Nascimento"');
45-
match(result.cartorio, /^\d{6}$/, 'O código do cartório deve ter 6 dígitos');
46-
match(result.estado, /^\d{2}$/, 'O código do estado deve ter 2 dígitos');
47-
match(result.anoRegistro, /^\d{4}$/, 'O ano de registro deve ter 4 dígitos');
48-
strictEqual(result.tipoLivro, '1001', 'Tipo de livro deve ser "1001" para certidão de nascimento');
44+
strictEqual(result.tipoCertidao, 'Nascimento', 'Certificate type should be "Nascimento"');
45+
match(result.cartorio, /^\d{6}$/, 'Registry office code must have 6 digits');
46+
match(result.estado, /^\d{2}$/, 'State code must have 2 digits');
47+
match(result.anoRegistro, /^\d{4}$/, 'Registration year must have 4 digits');
48+
strictEqual(result.tipoLivro, '1001', 'Book type should be "1001" for birth certificate');
4949
});
5050

51-
test('Geração de objeto detalhado para certidão de casamento', () => {
51+
test('Generate detailed object for marriage certificate', () => {
5252
const result = certidao.casamentoObj();
53-
strictEqual(result.tipoCertidao, 'Casamento', 'Tipo da certidão deve ser "Casamento"');
54-
match(result.cartorio, /^\d{6}$/, 'O código do cartório deve ter 6 dígitos');
55-
match(result.estado, /^\d{2}$/, 'O código do estado deve ter 2 dígitos');
56-
match(result.anoRegistro, /^\d{4}$/, 'O ano de registro deve ter 4 dígitos');
57-
strictEqual(result.tipoLivro, '2001', 'Tipo de livro deve ser "2001" para certidão de casamento');
53+
strictEqual(result.tipoCertidao, 'Casamento', 'Certificate type should be "Casamento"');
54+
match(result.cartorio, /^\d{6}$/, 'Registry office code must have 6 digits');
55+
match(result.estado, /^\d{2}$/, 'State code must have 2 digits');
56+
match(result.anoRegistro, /^\d{4}$/, 'Registration year must have 4 digits');
57+
strictEqual(result.tipoLivro, '2001', 'Book type should be "2001" for marriage certificate');
5858
});
5959

60-
test('Geração de objeto detalhado para certidão de óbito', () => {
60+
test('Generate detailed object for death certificate', () => {
6161
const result = certidao.obitoObj();
62-
strictEqual(result.tipoCertidao, 'Óbito', 'Tipo da certidão deve ser "Óbito"');
63-
match(result.cartorio, /^\d{6}$/, 'O código do cartório deve ter 6 dígitos');
64-
match(result.estado, /^\d{2}$/, 'O código do estado deve ter 2 dígitos');
65-
match(result.anoRegistro, /^\d{4}$/, 'O ano de registro deve ter 4 dígitos');
66-
strictEqual(result.tipoLivro, '3001', 'Tipo de livro deve ser "3001" para certidão de óbito');
62+
strictEqual(result.tipoCertidao, 'Óbito', 'Certificate type should be "Óbito"');
63+
match(result.cartorio, /^\d{6}$/, 'Registry office code must have 6 digits');
64+
match(result.estado, /^\d{2}$/, 'State code must have 2 digits');
65+
match(result.anoRegistro, /^\d{4}$/, 'Registration year must have 4 digits');
66+
strictEqual(result.tipoLivro, '3001', 'Book type should be "3001" for death certificate');
6767
});
6868

69-
test('Geração de certidão aleatória', () => {
69+
test('Generate random certificate', () => {
7070
const result = certidao.aleatoriaObj();
71-
match(result.tipoCertidao, /^(Nascimento|Casamento|Óbito)$/, 'Tipo da certidão aleatória deve ser "Nascimento", "Casamento" ou "Óbito"');
72-
match(result.cartorio, /^\d{6}$/, 'O código do cartório deve ter 6 dígitos');
73-
match(result.estado, /^\d{2}$/, 'O código do estado deve ter 2 dígitos');
74-
match(result.anoRegistro, /^\d{4}$/, 'O ano de registro deve ter 4 dígitos');
71+
match(result.tipoCertidao, /^(Nascimento|Casamento|Óbito)$/, 'Random certificate type should be "Nascimento", "Casamento" or "Óbito"');
72+
match(result.cartorio, /^\d{6}$/, 'Registry office code must have 6 digits');
73+
match(result.estado, /^\d{2}$/, 'State code must have 2 digits');
74+
match(result.anoRegistro, /^\d{4}$/, 'Registration year must have 4 digits');
7575
});
7676

77-
test('Geração de certidão aleatória com máscara', () => {
77+
test('Generate random certificate with mask', () => {
7878
const result = certidao.aleatoria();
79-
match(result, /^\d{6} \d{2} \d{4} \d{4} \d \d{5} \d{3} \d{7}$/, 'A máscara da certidão aleatória está incorreta');
79+
match(result, /^\d{6} \d{2} \d{4} \d{4} \d \d{5} \d{3} \d{7}$/, 'Random certificate mask is incorrect');
8080
});
8181

82-
test('Geração de certidão aleatória sem máscara', () => {
82+
test('Generate random certificate without mask', () => {
8383
const result = certidao.aleatoria(false);
84-
match(result, /^\d{32}$/, 'O número de certidão aleatória sem máscara deve ter 32 dígitos');
84+
match(result, /^\d{32}$/, 'Random certificate number without mask must have 32 digits');
8585
});
8686
});

test/endereco.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test';
22
import { strictEqual } from 'node:assert';
33
import { endereco } from 'gerador-br';
44

5-
describe('Endereço Generator', () => {
5+
describe('Address Generator', () => {
66
test('should generate a valid address with mask', () => {
77
const addressWithMask = endereco(true);
88
strictEqual(addressWithMask.cep.length, 9);

test/escolaridade.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test';
22
import { strictEqual } from 'node:assert';
33
import { escolaridade } from 'gerador-br';
44

5-
describe('Escolaridade Generator', () => {
5+
describe('Education Level Generator', () => {
66
test('should generate a valid education level', () => {
77
const educationLevel = escolaridade();
88
strictEqual(typeof educationLevel, 'string');

test/genero.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { describe, test } from 'node:test';
22
import { strictEqual, ok } from 'node:assert';
33
import { genero } from 'gerador-br';
44

5-
describe('Genero Generator', () => {
5+
describe('Gender Generator', () => {
66
test('should return "Feminino" for input "f"', () => {
77
strictEqual(genero('f'), 'Feminino');
88
});

0 commit comments

Comments
 (0)