mardi 17 juillet 2018

Mocha -Mongodb multiple test files

|--databaseproject |--app.js |--test |--test.js |--auth.js

How does "npm run test" actually run the code in my app.js the app.js file is not in the test directory (i know there is a hook).In my package.json i have set test:"mocha" ..

app.js

const mongoose=require("mongoose")
const Schema=mongoose.Schema
 const UserSchema=new Schema({
      name:String
  })
const User=mongoose.model('users',UserSchema) 
  module.exports=User
  beforeEach((done)=>{
    mongoose.connection.collections.users.drop(()=>{
      console.log("dropped")
      done()
    })
  })

Aucun commentaire:

Enregistrer un commentaire