WDIO Webpack Service

raw JSON →
1.0.1 verified Fri May 01 auth: no javascript deprecated

WebdriverIO service that builds webpack bundles before running tests. Current stable version is 1.0.1, with webpack 1.x as a peer dependency. Allows bundling static assets via webpack and provides options for custom webpack configuration, driver-specific overrides, and logging. Designed for WebdriverIO v4 and earlier; does not support modern WebdriverIO or webpack versions.

error Error: Cannot find module 'webpack'
cause webpack is not installed as a peer dependency (required webpack 1.x).
fix
npm install webpack@1 --save-dev
error TypeError: webpack is not a function
cause Webpack 2+ is installed and incompatible with this package's require pattern.
fix
Downgrade to webpack 1.x or use a different service.
deprecated Package is no longer maintained and only supports webpack 1.x.
fix Consider alternatives like wdio-static-server-service or custom onPrepare hook.
gotcha webpack 1.x peer dependency is outdated and incompatible with modern webpack projects.
fix Do not use with webpack 2+; use an alternative service.
gotcha Options must be passed as a nested array: services: [['webpack', { ... }]]
fix Use the correct array format shown in the documentation.
npm install wdio-webpack-service
yarn add wdio-webpack-service
pnpm add wdio-webpack-service

Shows how to configure the webpack service in wdio.conf.js, specifying webpack config, driver overrides, and logging.

// wdio.conf.js
const path = require('path');

exports.config = {
  // ...
  services: [
    ['webpack', {
      webpackConfig: {
        entry: path.resolve(__dirname, 'src/index.js'),
        output: {
          path: path.resolve(__dirname, 'dist'),
          filename: 'bundle.js'
        },
        resolve: {
          extensions: ['.js']
        }
      },
      webpackDriverConfig: {
        output: {
          path: path.resolve(__dirname, 'test/assets')
        }
      },
      webpackLog: true
    }]
  ],
  // ...
};