This repository contains various test scripts to verify the functionality of the ENS validator module.
npm install check-ensbash
npm install
`
Available Test Scripts
The following test scripts are available:
$3
Runs basic tests without any mocking, which will make actual API calls:
`bash
npm test
`
$3
Runs tests with mocked HTTP requests to prevent actual API calls:
`bash
npm run test:mock
`
$3
Runs comprehensive tests using the Jest testing framework:
`bash
npm run test:jest
`
Test Files
- test.js - Basic test script that makes actual API calls
- test-with-mock.js - Tests with mocked HTTP requests using Nock
- jest-test.js - Jest test suite with more comprehensive mocking and assertions
Important Notes
- The mocked tests will not send any actual requests to external APIs
- The basic test (test.js) will make actual API calls, which might result in real data being sent
- If you're testing in a production environment, always use the mocked tests
Troubleshooting
If you encounter any issues running the tests:
1. Make sure all dependencies are installed
2. Check that the module path is correct in the test files
3. Ensure you have proper network connectivity for the non-mocked tests
This is a very simple npm module.
My Module
A brief description of my module.
Installation
`bash
npm install check-ens
`
Usage
$3
`javascript
const { validateENS } = require('check-ens');
// Example usage with async/await
async function example() {
try {
const result = await validateENS('example.eth');
console.log('Validation result:', result);
} catch (error) {
console.error('Validation error:', error);
}
}
example();
`
$3
The package includes TypeScript declarations:
`typescript
import { validateENS, ValidationResponse } from 'check-ens';
// Example usage with async/await
async function example() {
try {
const result: ValidationResponse = await validateENS('example.eth');
console.log('Validation result:', result);
// Access typed properties
if (result.success) {
console.log('Message:', result.message);
} else {
console.error('Error:', result.error);
}
} catch (error) {
console.error('Validation error:', error);
}
}
example();
`
API
$3
Validates an ENS name or processes text data.
- Parameters:
- data (string): The text or ENS name to validate.
- Returns:
- Promise: A promise that resolves to the validation result.
Types
`typescript
interface ValidationResponse {
success?: boolean;
message?: string;
result?: any;
error?: string;
[key: string]: any; // Additional properties
}
``