Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to exclude "node_modules" #44

Closed
zatziky opened this issue Aug 26, 2016 · 3 comments
Closed

How to exclude "node_modules" #44

zatziky opened this issue Aug 26, 2016 · 3 comments

Comments

@zatziky
Copy link

zatziky commented Aug 26, 2016

How can I exclude node_modules from the run?

mocha-webpack

I thought that webpack-node-externals were meant for this task. This is my webpack.test-config.js:

const nodeExternals = require('webpack-node-externals');
const config = {};

// in order to ignore built-in modules like path, fs, etc.
config.target = 'node';

// in order to ignore all modules in node_modules folder
config.externals = [nodeExternals()];

config.output = {
    // sourcemap support for IntelliJ/Webstorm
    devtoolModuleFilenameTemplate: '[absolute-resource-path]',
    devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]?[hash]'
};

// 'cheap-module-source-map' faster than 'source-map'
config.devtool = "source-map";


module.exports = config;

I run the tests from package.json:

"test": "mocha-webpack --webpack-config webpack.config-test.js \"**/test/*.test.js\"",

@zinserjan
Copy link
Owner

webpack-node-externals just marks the modules as external, so these modules are not included into the final js. But they will be evaluated and executed as usual.

Your pattern \"**/test/*.test.js\" searches also in node_modules for folders with name test and files ending with .test.js. Thats your issue, right?

Your project structure leads me to a few questions. Normally, when projects depending on a transpiling step like babel or webpack, they organize their code in a seperate src folder to make code generation into a dist folder easier.
This and the case that I don't see a normal webpack config leads me to the question if you really need webpack to run your node server. Are you using webpack to compile your project before running your server? Or just wanna test? Then plain mocha would be enough.

@zatziky
Copy link
Author

zatziky commented Aug 31, 2016

@zinserjan, the reasons I want to use moda-webpack are 2:

  1. to have same environment for FE and BE tests. Since we use PhpStorm IDE there is only 1 mocha per running configuration. (I have to choose either mocha or mocha-webpack.
  2. mocha --watch is said to be very CPU intensive. link It also will be deprecated. link

Anyways, I changed my project structure so that all sources of BE are under one folder and node_modules are apart.

I am not sure whether to close the issue. I leave it open and see if this would lead to add an exlude alternative...

@zinserjan zinserjan mentioned this issue Dec 5, 2016
22 tasks
@zinserjan
Copy link
Owner

When #79 will be released it's possible to pass each directory as an entry to mocha-webpack.

"test": "mocha-webpack --webpack-config webpack.config-test.js \"controller/**/test/*.test.js\" \"cron/**/test/*.test.js\"",

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants