Skip to content

Commit

Permalink
Replace require-dir to get jest test working
Browse files Browse the repository at this point in the history
require-dir is not compatible with jest, but require-directory seems to work

aseemk/requireDir#53 (comment)
  • Loading branch information
Stefan Buck committed Apr 2, 2018
1 parent 259b8fc commit ec2148f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"memory-cache": "^0.2.0",
"newrelic": "^2.2.2",
"promise-limit": "^2.6.0",
"require-dir": "^0.3.2"
"require-directory": "^2.1.1"
},
"repository": {
"type": "git",
Expand Down
5 changes: 3 additions & 2 deletions src/plugins/java-resolver.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const Joi = require('joi');
const path = require('path');
const Boom = require('boom');
const requireDir = require('require-dir');
const requireDir = require('require-directory');
const insight = require('../utils/insight.js');

const mappingFiles = requireDir('../../mapping-files');
const mappingFiles = requireDir(module, path.join(__dirname, '../../mapping-files'));
const flatMappingList = Object.assign(...Object.values(mappingFiles));

const register = (server) => {
Expand Down
7 changes: 4 additions & 3 deletions test/functional.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const got = require('got');
describe('functional', () => {
let server;

beforeAll((done) => {
beforeAll(() => (new Promise((resolve) => {
server = require('../server'); // eslint-disable-line global-require
server.events.once('start', done);
});
server.events.once('start', resolve);
})));

afterAll(() => server.stop());

Expand Down Expand Up @@ -34,6 +34,7 @@ describe('functional', () => {
testUrl('/ping?url=https://nodejs.org/api/path.html', 'https://nodejs.org/api/path.html');

it('resolves /bulk request', async () => {
console.log('yyy');
const response = await got.post(`${server.info.uri}/bulk`, {
body: JSON.stringify([
{ type: 'registry', registry: 'composer', target: 'phpunit/phpunit' },
Expand Down
4 changes: 0 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3563,10 +3563,6 @@ request@^2.83.0:
tunnel-agent "^0.6.0"
uuid "^3.1.0"

require-dir@^0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/require-dir/-/require-dir-0.3.2.tgz#c1d5c75e9fbffde9f2e6b33e383db4f594b5a6a9"

require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
Expand Down

0 comments on commit ec2148f

Please sign in to comment.