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.
https://opportunity-calendar.herokuapp.com/
MIT License
15 stars 30 forks source link

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

Closed Manvityagi closed 3 years ago

Manvityagi commented 3 years ago
Athira2199 commented 3 years ago

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.

Manvityagi commented 3 years ago

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

Sukriti-sood commented 3 years ago

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

Manvityagi commented 3 years ago

@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.

Sukriti-sood commented 3 years ago

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

Manvityagi commented 3 years ago

@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

Manvityagi commented 3 years ago

@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.

Manvityagi commented 3 years ago

@Sukriti-sood Any updates?

Sukriti-sood commented 3 years ago

@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.

Sukriti-sood commented 3 years ago

@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 commented 3 years ago

@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 commented 3 years ago

@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`
Sukriti-sood commented 3 years ago

@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

Manvityagi commented 3 years ago

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

Manvityagi commented 3 years ago

Will update you soon on it @Sukriti-sood