TESTING GUIDE
Testing Guide for Nekazari Modules
Section titled “Testing Guide for Nekazari Modules”Guide for testing your module locally before uploading to the platform.
Local Development Setup
Section titled “Local Development Setup”1. Start Development Server
Section titled “1. Start Development Server”npm run devThis starts the module on http://localhost:5003 with Vite proxy configured.
2. Configure API Proxy
Section titled “2. Configure API Proxy”The template includes a Vite proxy in vite.config.ts that forwards /api requests to the Nekazari platform.
For testing with real API:
-
Get a token from the staging/production environment:
- Log in to the platform
- Open browser DevTools → Application → Local Storage
- Find
keycloak-tokenor check Network tab for Authorization header
-
Update
vite.config.tsproxy configuration:
server: { proxy: { '/api': { target: 'https://nkz.artotxiki.com', changeOrigin: true, secure: true, configure: (proxy, _options) => { proxy.on('proxyReq', (proxyReq, req, _res) => { proxyReq.setHeader('Authorization', 'Bearer YOUR_TOKEN_HERE'); proxyReq.setHeader('X-Tenant-ID', 'your-tenant-id'); }); }, }, },},3. Mock Data for Development
Section titled “3. Mock Data for Development”If you don’t have access to a real environment, you can create mock data:
Create src/mocks/api.ts:
export const mockEntities = [ { id: 'urn:ngsi-ld:Sensor:001', type: 'Sensor', name: 'Temperature Sensor', temperature: { value: 22.5, unitCode: 'CEL' }, location: { type: 'GeoProperty', value: { type: 'Point', coordinates: [-3.0, 40.0] } } }];
export const mockParcels = [ { id: 'parcel-001', name: 'Field A', area: 5000, location: { type: 'Polygon', coordinates: [[[-3.0, 40.0], [-3.1, 40.0], [-3.1, 40.1], [-3.0, 40.1], [-3.0, 40.0]]] } }];Use mocks in development:
import { mockEntities } from './mocks/api';
const MyComponent: React.FC = () => { const [entities, setEntities] = useState([]);
useEffect(() => { if (import.meta.env.DEV) { // Use mock data in development setEntities(mockEntities); } else { // Use real API in production const client = new NKZClient({ /* ... */ }); client.get('/entities').then(setEntities); } }, []);};Testing Checklist
Section titled “Testing Checklist”Before uploading your module:
- Module builds without errors (
npm run build) - All TypeScript types are correct (
npm run typecheck) - Module loads correctly in development server
- API calls work (or mocks work)
- UI components render correctly
- Authentication flow works (if applicable)
- Error handling works
- Loading states work
- Responsive design works (mobile/tablet/desktop)
-
manifest.jsonis valid - Icon and assets are included
- Module exports default component
Common Issues
Section titled “Common Issues”CORS Errors
Section titled “CORS Errors”Problem: Access to fetch at '...' has been blocked by CORS policy
Solution: Use the Vite proxy (already configured) or ensure CORS is enabled for your development domain.
Module Not Loading
Section titled “Module Not Loading”Problem: Module doesn’t appear in the platform
Check:
manifest.jsonis valid JSONbuild_config.scopematchesvite.config.tsfederation nameremoteEntry.jsexists indist/assets/- Component exports default
Authentication Not Working
Section titled “Authentication Not Working”Problem: useAuth() returns undefined or null
Solution: Ensure you’re testing within the platform context. In standalone development, you may need to mock authentication.
Testing in Production Environment
Section titled “Testing in Production Environment”Once your module is uploaded:
- Check validation status via API or admin panel
- Activate the module for your tenant
- Test in the actual platform environment
- Verify all features work with real data
- Check performance and loading times
Support
Section titled “Support”For testing issues:
- Email: developers@nekazari.com
- Check External Developer Guide troubleshooting section