FrontendDeveloper.in

Vue.js question detail

What is the procedure to run tests in node?

By proper mocking, you can bundle tests with webpack and run them on node without having depenceny on Browser API. It involves 2 steps,

  1. Create webpack config: Create webpack config with proper .babelrc
// webpack.config.js
module.exports = {
entry: './test.js',
output: {
path: __dirname,
filename: 'test-bundle.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
}
]
}
}
  1. Run testcases: First you need to bundle and then run them using mocha as below,
webpack
mocha test-bundle.js
Back to all Vue.js questions
Get LinkedIn Premium at Rs 399