Thomas Preston
Thomas Preston

Reputation: 707

Unable to require webpack config in karma.config.js

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

Upvotes: 0

Views: 93

Answers (1)

Thomas Preston
Thomas Preston

Reputation: 707

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.

Upvotes: 0

Related Questions