Tuesday, 18 April 2017

Mocha: Cannot find module

The app structure is like this: index.js -src --db ---index.js ---model.js -test --test.js In my index.js, I have to import database like this const db = require('./src/db') The app runs well when use npm run However, when I try to run the test with mocha, it gives me error Error: Cannot find module './src/db' My test.js file is below:

// Dev-Dependecies
const chai = require('chai')
const chaiHttp = require('chai-http')
const should = chai.should()

const app = require('./index')

chai.use(chaiHttp)


via JSNoob

No comments:

Post a Comment