Unable to require webpack config in karma.config.js

37 Views Asked by At

I have a webpack config file I would like to require to use in karma.config.js. This is the contents of the webpack config file:

const { merge } = require('webpack-merge');
const commonConfig = require('./webpack.common');
const developmentConfig = require('./webpack-config/webpack.development');
module.exports = merge(commonConfig, developmentConfig, { mode: 'development' });

Then in my karma.config.js I attempt to require this file like so:

const webpackConfig = require('../webpack.development');

However, when I run npm run test the console reports that \test\karma.config.js doesnt exist. If I remove this require, it sees the file. So far in my research this seems like it was an older known issue, however I've yet to find a valid work around.

I'm currently working with webpack 5.75.0, karma 6.4.1, and karma-webpack 5.0.0

1

There are 1 best solutions below

0
Thomas Preston On

Posting this answer so that posterity might know my shame. When switching between branches where the package.json differs, always remember to npm install kids. That was my issue.