feat(test): implementazione infrastruttura completa (Unit, Integration, E2E) con Vitest e Playwright
- Introduce Vitest per Unit e Integration Test. - Introduce Playwright per End-to-End Test. - Aggiuge documentazione dettagliata in tests/README.md. - Aggiorna .gitignore per escludere i report di coverage
This commit is contained in:
22
tests/unit/server-utils.test.js
Normal file
22
tests/unit/server-utils.test.js
Normal file
@@ -0,0 +1,22 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { printServerInfo } from '../../src/server-utils.js'
|
||||
|
||||
// Mocking console.log per evitare output sporchi durante i test
|
||||
import { vi } from 'vitest'
|
||||
|
||||
describe('Server Utils', () => {
|
||||
it('printServerInfo dovrebbe stampare le porte corrette', () => {
|
||||
const consoleSpy = vi.spyOn(console, 'log')
|
||||
printServerInfo(3000, 3001)
|
||||
|
||||
expect(consoleSpy).toHaveBeenCalled()
|
||||
|
||||
// Unisce tutti i messaggi loggati in un'unica stringa per facilitare la ricerca
|
||||
const allLogs = consoleSpy.mock.calls.map(args => args[0]).join('\n')
|
||||
|
||||
expect(allLogs).toContain('3000')
|
||||
expect(allLogs).toContain('3001')
|
||||
|
||||
consoleSpy.mockRestore()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user