Skip to content

Commit

Permalink
force axios to use http adapter
Browse files Browse the repository at this point in the history
If jest/jsdom is used then a polyfill for xhr is created which will cause axios to default the adapter to it. Since jsdom logs all errors use of wait-on will have any failed attempts to connect logged which is rather noisy and misleading.

By forcing axios to use the node.js http adapter instead this problem is bypassed keeping logs clean.
  • Loading branch information
jeffbski committed Jun 6, 2020
1 parent 3cf0b64 commit 35412e9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/wait-on.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ const Joi = require('@hapi/joi');
const https = require('https');
const net = require('net');
const util = require('util');
const axios = require('axios').default;
const axiosPkg = require('axios').default;
const axiosHttpAdapter = require('axios/lib/adapters/http');
const { isBoolean, isEmpty, negate, noop, once, partial, pick, zip } = require('lodash/fp');
const { NEVER, combineLatest, from, merge, throwError, timer } = require('rxjs');
const { distinctUntilChanged, map, mergeMap, scan, startWith, take, takeWhile } = require('rxjs/operators');

// force http adapter for axios, otherwise if using jest/jsdom xhr might
// be used and it logs all errors polluting the logs
const axios = axiosPkg.create({ adapter: axiosHttpAdapter });
const isNotABoolean = negate(isBoolean);
const isNotEmpty = negate(isEmpty);
const fstat = promisify(fs.stat);
Expand Down

0 comments on commit 35412e9

Please sign in to comment.