I want to Mocha test to apply to only one local file about.handlebars. Here is my project structure:
app root
views
about.handlebars
test
main_test.js
When I add var about = require('./views/about.handlebars');
I receive an error:
Error: Cannot find module './views/about.handlebars’
When I use import {about} from './views/about.handlebars';
I get another error message
SyntaxError: Unexpected token import
Does anyone worked with Mocha and encountered similar problems? Any help is very much appreciated!
Thank you everyone for your answers! There was indeed a problem with a path and handlebars needed to be compiled too. I made the corrections and now it works!
var fs = require('fs');
var handlebars = require('handlebars');
require.extensions['.hbs'] = function (module, filename) {
module.exports = handlebars.compile;
var raw = fs.readFileSync(filename).toString();
}
var assert = require('chai').assert;
var about = require('../views/about.handlebars');