Testing
Recommended strategy
- Unit tests — with mocks of the HTTP client. Verify that the logic builds the correct JSON.
- Integration tests — use a test key (future
lxs_test_*) or a test tenant. - End-to-end — issuance should be performed against Hacienda’s test environment.
Test tenant
Important: There is currently no public sandbox. Ask the administrator to create a dedicated test tenant, with its own API key and a test P12 certificate.
Server mock (Node)
import nock from 'nock';
beforeAll(() => {
nock('https://api.pos.lxsyscr.com')
.post('/api/v1/facturas')
.reply(201, {
clave: '506...',
numeroConsecutivo: '001...',
tipoDocumento: '01',
estadoHacienda: 'procesando',
totalComprobante: 100,
moneda: 'CRC',
fechaEmision: new Date().toISOString()
});
});Webhook testing
webhook.site can be used, or your own receiver exposed with ngrok. Issue a document and observe the callback.