Speak now
Please Wait Image Converting Into Text...
Embark on a journey of knowledge! Take the quiz and earn valuable credits.
Challenge yourself and boost your learning! Start the quiz now to earn credits.
Unlock your potential! Begin the quiz, answer questions, and accumulate credits along the way.
General Tech QA/Testing 2 years ago
Posted on 16 Aug 2022, this text provides information on QA/Testing related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.
Turn Your Knowledge into Earnings.
i'm currently developping a nodejs/express rest api (personal project), and i wanted to learn as much as i ca from this project.
So in my project i'm using sequelize as an ORM layer, i have a model named `bus, and i have build CRUD endpoint to this model.
sequelize
ORM
now i want to do some test this model/api i have developped, i read some tutorial about testing and found that there are multiple type of testing seperated in two big categories : white-box vs black-box.
So i have written some integration tests that test my api(integration test are black-box testing)
and i want right know to write some unit-testing, but i don't know what to test, the bus model is a Sequelize model, so everything that i would test would be already tested in the sequelize library it self. and testing the api endpoints is done via integration tests.
bus
PS: its my first time writing tests.
i'm using the following technologies : nodejs, sequelize, express, mocha, chai.
nodejs
express
mocha
chai
Bus Model Definition
const Sequelize = require('sequelize'); module.exports = function(sequelize) { let Bus = sequelize.define('bus', { name: { type: Sequelize.STRING, }, }); Bus.associate = function(models) { Bus.hasOne(models.LaneBus, { foreignKey: 'busId' }); }; return Bus; }
Bus Api endpoint testings
const request = require('superagent'); const expect = require('chai').expect; const app = require('../../src/app'); var http = require('http'); const models = require('../../src/models'); describe("bus", function () { var bus_id; it('should create bus', function (done) { request.post('http://localhost:3000/bus') .type('form') .send({ name: 'bus_test_1', }).set('Accept', 'application/json') .set('Authorization', global.JWT_TOKEN_TEST_ADMIN) .end((err, res) => { expect(res.status).to.be.eq(201, 'invalid return code'); expect(res.body.status).to.be.eq('success', 'invalid retun status'); bus_id = res REPLY 0 views 0 likes 0 shares Facebook Twitter Linked In WhatsApp
No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.
General Tech 10 Answers
General Tech 7 Answers
General Tech 3 Answers
General Tech 9 Answers
General Tech 2 Answers
Ready to take your education and career to the next level? Register today and join our growing community of learners and professionals.