0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-30 22:34:10 -05:00
verdaccio/test/unit/modules/basic_system.spec.ts

67 lines
1.7 KiB
TypeScript
Raw Normal View History

import express from 'express';
import request from 'request';
import rimraf from 'rimraf';
2014-12-22 12:58:25 -05:00
import endPointAPI from '../../../src/api/index';
import { API_ERROR } from '../../../src/lib/constants';
import { setup } from '../../../src/lib/logger';
import config from '../partials/config/index';
setup([{ type: 'stdout', format: 'pretty', level: 'trace' }]);
2017-11-01 11:47:20 -05:00
const app = express();
const server = require('http').createServer(app);
describe('basic system test', () => {
2017-04-19 14:15:28 -05:00
let port;
jest.setTimeout(20000);
2014-12-22 12:58:25 -05:00
beforeAll(function (done) {
rimraf(__dirname + '/store/test-storage', done);
2017-04-19 14:15:28 -05:00
});
2014-12-22 12:58:25 -05:00
beforeAll(async function (done) {
app.use(await endPointAPI(config()));
2014-12-22 12:58:25 -05:00
server.listen(0, function () {
2017-04-19 14:15:28 -05:00
port = server.address().port;
done();
});
});
2014-12-22 12:58:25 -05:00
2017-11-01 11:47:20 -05:00
afterAll((done) => {
server.close(done);
});
// TODO: recieve aborted call [Error: aborted], please review
test.skip('server should respond on /', (done) => {
request(
{
url: 'http://localhost:' + port + '/',
timeout: 6000,
},
function (err, res, body) {
// TEMP: figure out why is flacky, pls remove when is stable.
// eslint-disable-next-line no-console
console.log('server should respond on / error', err);
expect(err).toBeNull();
expect(body).toMatch(/Verdaccio/);
done();
}
);
}, 10000);
2014-12-22 12:58:25 -05:00
test('server should respond on /___not_found_package', (done) => {
request(
{
url: `http://localhost:${port}/___not_found_package`,
},
function (err, res, body) {
expect(err).toBeNull();
expect(body).toMatch(API_ERROR.NO_PACKAGE);
done();
}
);
}, 10000);
2017-04-19 14:15:28 -05:00
});