I am new making unit test for restapis. I tested the api manually and all is working fine, then I try to setup the unit tests but there is giving me errors for every request that involves my MySQL database.
this is my index.test.js
// imports...
chai.should();
chai.use(chaiHttp);
describe("Testing...", () => {
describe("Basic test connection", () => {
it("Should print server status", (done) => {
chai.request(app)
.get('/')
.end((err, response) => {
response.should.have.status(200);
done();
});
});
});
describe("Test /artist GET", () => {
it("Should print all artists", (done) => {
chai.request(app)
.get('/artists')
.end((err, response) => {
response.should.have.status(200);
done();
});
});
});
});
The first test passed, but then the second one give me the following error:
Uncaught Error: getaddrinfo ENOUTFOUND mysqldb
at GetAddInfoReqWrap.onlookup [as oncomplete] (dns.js:66:26)
Would appreciate any comment