Test case in jasmine

183 Views Asked by At

I am very new to Jasmine. In fact, I just started today and don't have prior knowledge writing JS unit test cases. But I want to complete one task - I have a set of data like (model,type,vehicle) etc. in CSV format and uploaded that data into PostgreSQL database. Now I want to write a test case in Jasmine to check whether the data has been uploaded in the database is same to the csv file or not. Can anyone, please, help me on this?

1

There are 1 best solutions below

0
Ashvin777 On

Jasmine is a unit testing framework which generally works on mocking data. It's not an ideal case to do the background APIs calls in unit tests.

The only way I can think of handling this case is, for each Jasmine unit test you have to first load the data from API/DB using the HTTP/WebSocket call, and wait for that to finish and then apply your test. Just like below

describe('postgres-sql data verification', () => {
    it('data verification async task', (done) => {
        someService.getData().then(() => {
            //do the expect checks here and then
            done()
        })
    })
})

Make sure the test are running over some browser instance for example - PhantomJS or Chrome.

Or else - Why not write some API test which can check your CSV and database data validation?