@thecollege/azure-test-track
Version:
Azure DevOps utilities for test plan and test run management
121 lines (93 loc) • 2.79 kB
Markdown
The `azure-test-track` now has a configurable logging system that is **silent by default**.
By default, **info**, **warnings** and **errors** are displayed:
```bash
node your-script.js
```
**Typical output:**
```
[] Test points data retrieved with success. Test points found: 42
[] Test Run created with success. Test Run ID: 999
[] Warning: The following test case IDs were not found...
[] Test Run results updated successfully! Updated 42 test case(s).
```
### 2. Debug Mode (Verbose)
To see **all logs** (debug, info, warn, error):
```powershell
# PowerShell
$env:DEBUG='true'
node your-script.js
$env:DEBUG='true'; node your-script.js
```
**Typical output:**
```
[] Fetching plan ID for plan with name: E2E Tests
[] Plan found: E2E Tests with ID 789
[] Total suites found in plan with ID 789: 5
[] Test Run created with success. Test Run ID: 999
[] Build ID not found in environment variables...
[] Test Run results updated successfully! Updated 42 test case(s).
```
### 3. Custom Logger
You can inject your own logger (Winston, Pino, etc):
```javascript
const logger = require('@thecollege/azure-test-track/lib/logger');
const winston = require('winston');
// Configure your logger
const myLogger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.File({ filename: 'azure-test-track.log' })
]
});
// Inject into azure-test-track
logger.setLogger(myLogger);
// Now all logs will go to your logger
const { createTestRunByExecution } = require('@thecollege/azure-test-track');
await createTestRunByExecution(testSettings);
```
| Method | When It Appears | Example |
|--------|-----------------|---------|
| `debug` | Only with DEBUG=true | Internal details, resource IDs, payloads |
| `info` | Always | Main operations successfully completed |
| `warn` | Always | Warnings, test cases not found |
| `error` | Always | Critical errors that prevent execution |
```powershell
Remove-Item Env:\DEBUG
```
```yaml
- run: npm test
- run: npm test
env:
DEBUG: true
```
```yaml
- script: npm test
- script: npm test
env:
DEBUG: true
```
Run the included test scripts:
```powershell
node test-logger.js
$env:DEBUG='true'; node test-logger.js
node test-logger-real.js
$env:DEBUG='true'; node test-logger-real.js
```