Сделай свой npm пакет, напиши к нему небольшой тест, где проверяешь, что прокси действительно проверяются.
Что-то вроде:
const assert = require('assert'); const sinon = require('sinon'); const axios = require('axios'); const checkProxies = require('./your-file-name.js'); describe('checkProxies', () => { let axiosGetStub; beforeEach(() => { axiosGetStub = sinon.stub(axios, 'get'); }); afterEach(() => { axiosGetStub.restore(); }); it('should add good proxies to the goodProxys array', async () => { axiosGetStub.resolves({ status: 200 }); const proxies = ['1.2.3.4:80', '5.6.7.8:8080', '9.10.11.12:8888']; const goodProxys = []; await checkProxies(proxies, goodProxys); assert.deepStrictEqual(goodProxys, proxies); }); it('should not add bad proxies to the goodProxys array', async () => { axiosGetStub.rejects(new Error('Connection error')); const proxies = ['1.2.3.4:80', '5.6.7.8:8080', '9.10.11.12:8888']; const goodProxys = []; await checkProxies(proxies, goodProxys); assert.deepStrictEqual(goodProxys, []); }); });
