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

Unhandled rejection Error: not a directory #173

Closed
th3fallen opened this issue Sep 8, 2016 · 6 comments
Closed

Unhandled rejection Error: not a directory #173

th3fallen opened this issue Sep 8, 2016 · 6 comments

Comments

@th3fallen
Copy link

If this is indeed a support request please let me know and i'll move it. i belive it to be a bug however.

I'm submitting a bug report

Webpack version:
1.13.1

Webpack Karma version:
1.8.0

Karma version:
1.2.0

Please tell us about your environment:
OSX 10.12 beta 16A313a

Browser: Phantom

Current behavior:
when running tests i get the following failure:
Unhandled rejection Error: not a directory
full error with logging of current and path

this has only started after i began splitting app: and vendor: entry points

Expected/desired behavior:
should build and test correctly

webpack.config.js

var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var autoprefixer = require('autoprefixer');
import getConfig from './config';
var packages = require('./package.json');

const config = getConfig(process.env.NODE_ENV);

// Strip out all keys starting with _
const envConfig = (config) => {
  Object.keys(config)
    .filter(k => k[0] === '_')
    .forEach(k => delete config[k]);
  return config;
};

let publicPath = (config.PREFIX || '').replace(/\/$/, '') + path.join(process.env.PUBLIC_PATH || '').replace(/^\./, '');

module.exports = {
  devtool: 'source-map',
  entry: {
    app: [
      './app/shared/vendor/segment',
      './app/main',
    ],
    vendor: Object.keys(packages.dependencies),
  },
  output: {
    publicPath: publicPath || '/',
    path: path.join(__dirname, 'dist'),
    filename: 'assets/js/[name]-[hash].js',
  },
  resolve: {
    root: path.join(__dirname, 'app'),
    modulesDirectories: [
      'node_modules',
    ],
  },
  plugins: [
    new webpack.DefinePlugin({
      ENV: JSON.stringify(envConfig({
        ...config,
        PUBLIC_PATH: process.env.PUBLIC_PATH,
        ENV: process.env.NODE_ENV,
      })),
    }),
    new ExtractTextPlugin('assets/css/[name]-[hash].css', { allChunks: true }),
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'app/index.html',
      chunksSortMode: 'dependency',
    }),
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks: Infinity,
    }),
  ],
  module: {
    loaders: [
      {
        test: /\.js$/,
        loaders: ['babel'],
        include: path.join(__dirname, 'app'),
      },
      {
        test: /\.(scss|css)$/,
        loader: ExtractTextPlugin.extract('style', ['css?sourceMap', 'postcss', 'sass?sourceMap']),
      },
      {
        test: /\.(woff|woff2|eot|ttf|svg)$/,
        loader: 'url?name=assets/img/[name]-[hash:6].[ext]&limit=20000',
      },
      {
        test: /\.(png|jpe?g|gif)$/,
        loader: 'file?name=assets/img/[name]-[hash:6].[ext]',
      },
      {
        test: /\.json$/,
        loader: 'json',
      },
    ],
  },
  postcss: [autoprefixer({ browsers: ['last 2 versions'] })],
};

test.js

'use strict';
const watch = process.argv.slice(2) == 'watch';
var karma = require('karma');

new karma.Server({
  singleRun: !watch,
  configFile: __dirname + '/../karma.conf.js',
  reporters: ['junit', 'progress', 'coverage'],
  junitReporter: {
    suite: 'app',
    outputDir: './reports/',
  },
}, (exitCode) => {
  process.exit(exitCode);
}).start();

@MikaAK
Copy link
Contributor

MikaAK commented Sep 9, 2016

#149 also if that doesn't solve your issue link your karmaConfig

@th3fallen
Copy link
Author

I should mention this exact config works fine if i dont have multiple entry points

karma.conf

import webpackConfig from './webpack.config';

module.exports = function (config) {
  config.set({
    port: 9876,
    runnerPort: 9100,
    logLevel: config.LOG_INFO,
    captureTimeout: 30000,
    basePath: '',

    frameworks: ['mocha', /*'sinon-stub-promise', 'sinon-chai', 'sinon',*/ 'chai'],

    files: [
      'node_modules/babel-polyfill/dist/polyfill.js',
      { pattern: 'app/**/*.spec.js', watched: false },
    ],

    reporters: ['progress', 'coverage'],

    preprocessors: {
      'app/**/*.js': ['webpack', 'sourcemap'],
    },

    client: {
      captureConsole: true,
    },

    webpack: {
      ...webpackConfig,
      module: {
        ...webpackConfig.module,
      },
      externals: {
        'cheerio': 'window',
        'react/addons': true,
        'react/lib/ExecutionEnvironment': true,
        'react/lib/ReactContext': true,
      },
    },
    webpackMiddleware: {
      // webpack-dev-middleware configuration
      stats: 'errors-only',
    },

    browsers: ['PhantomJS'],

    coverageReporter: {
      dir: 'reports/coverage/',
      includeAllSources: true,
      reporters: [
        { type : 'html', subdir: 'html' },
        { type: 'lcov', subdir: 'lcov' },
      ],
    },
  });
};

@timothylombrana
Copy link

@th3fallen were you able to find a resolution, i have the exact problem myself.

@th3fallen
Copy link
Author

th3fallen commented Mar 9, 2017

@alphapilgrim i was, my solution was to use jest instead 🙈

@joshwiens joshwiens removed their assignment Mar 9, 2017
@jacobthemyth
Copy link

FWIW, I had this same error and fixed it by deleting my entry in karma.conf.js.

karma.conf.js

var webpackConfig = require('./webpack.config')('test');
delete webpackConfig.entry;

module.exports = function(config) {
  config.set({
    // ...
    webpack: webpackConfig
  })
}

@codymikol
Copy link
Owner

Closing as this is on an older version of karma-webpack that will not receive updates, if you are having the same issues with a current build, open another ticket and I'll assist as best I can!

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

No branches or pull requests

6 participants