mardi 23 octobre 2018

Testing with Mocha

I am trying to test my app using Mocha. Like so:

it('should throw error if FILE already exists', function () {
    const path = 'test/styles/header/style.css'
    createNew(path).catch(err => {
        return assert.equal(err, 'already exists')
    })
})

and createNew:

const createNew = function(path) {
    return new Promise((resolve, reject) => {
        if (fs.existsSync(providedPath)) {
           reject('already exists')
           return
        }
...

Is it good practice to test promises the way i am doing it?

Aucun commentaire:

Enregistrer un commentaire