Girl-Code-It / Opportunity-Calendar-Backend

Opportunity Calendar is the one-stop place to refer important opportunities available in tech-space like newly posted jobs, internships, hackathons, tech-conferences, scholarships, etc.

Home Page:https://opportunity-calendar.herokuapp.com/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Write Unit-Test For POST Opportunity API using Chai, Mocha and Sinon

Manvityagi opened this issue · comments

  • The POST Opportunity API is divided into controllers, services, and managers,
    Tests should be written for each 3 of them.
  • Data should be mocked with Sinon.
  • This is the first test, so set up for chai, mocha also needs to be done.
  • Refer to this for help

Hi, I have never done unit-testing in NodeJS but would love to explore the opportunity if given a chance. Since the issue is opened please allow me to take up the oppurtunity.

Hi, I have never done unit-testing in NodeJS but would love to explore the opportunity if given a chance. Since the issue is opened please allow me to take up the oppurtunity.

Hi @Athira2199, there is an issue assigned to you already, only 1 issue can be assigned at one time. Please complete that first

@Manvityagi I would like to work on this, Please Assign this to me

@Manvityagi I would like to work on this, Please Assign this to me

Assigned @Sukriti-sood, Go ahead.
Feel free to ping on discord channel #opportunity-calendar-backend in case of any doubts.

@Manvityagi I have written tests for manager and services facing problem in controllers like how to compare status code and json data.

@Manvityagi I have written tests for manager and services facing problem in controllers like how to compare status code and json data.

Let's connect after Holi @Sukriti-sood

@Sukriti-sood
In this article, Refer to the last part- UserContoller class, you will get a fair enough idea of how to write tests for our controllers.
https://blog.logrocket.com/unit-testing-node-js-applications-using-mocha-chai-and-sinon/

If you still face any problems, feel free to ping.

@Sukriti-sood Any updates?

@Sukriti-sood Any updates?

I have wriitten tests for manager and services and I am getting some errors while running tests related to require

Require Reference not found ESM modeule,
Trying to resolve them ,

I will try to complete this issue today.

@Manvityagi Please help me I am continuously getting this Error
Earlier I was writing test in develop branch then I realised I haven't created Feature branch from that time I am getting this Error

Screenshot from 2021-04-03 16-35-54

@Manvityagi Please help me I am continuously getting this Error
Earlier I was writing test in develop branch then I realised I haven't created Feature branch from that time I am getting this Error

Screenshot from 2021-04-03 16-35-54

Try using import in place of require

import chai from 'chai'; 
import sinon from 'sinon'; 
import stubValue from './fakedata';

//same for all other `require`

@Manvityagi Please help me I am continuously getting this Error
Earlier I was writing test in develop branch then I realised I haven't created Feature branch from that time I am getting this Error
Screenshot from 2021-04-03 16-35-54

@Sukriti-sood Try using import in place of require

import chai from 'chai'; 
import sinon from 'sinon'; 
import stubValue from './fakedata';

//same for all other `require`

@Manvityagi Please help me I am continuously getting this Error
Earlier I was writing test in develop branch then I realised I haven't created Feature branch from that time I am getting this Error
Screenshot from 2021-04-03 16-35-54

Try using import in place of require

import chai from 'chai'; 
import sinon from 'sinon'; 
import stubValue from './fakedata';

//same for all other `require`

I have tried this also for this I am getting module not defined

Screenshot from 2021-04-03 21-40-52

Can you pull the latest changes from repo and make a PR as it is.. So that I can debug on my system? @Sukriti-sood

Will update you soon on it @Sukriti-sood