1. webpack-tape-run
The excellent tape-run ported as Webpack plugin
webpack-tape-run
Package: webpack-tape-run
Created by: syarul
Last modified: Wed, 29 Jun 2022 00:11:07 GMT
Version: 1.0.3
License: MIT
Downloads: 58
Repository: https://github.com/syarul/webpack-tape-run

Install

npm install webpack-tape-run
yarn add webpack-tape-run

webpack-tape-run

npm package
Build status

Run tape-run as webpack plugin

Runs webpack with the generated output bundle in browser with tape-run (headless or non-headless).
This works well with webpack --watch as it will run your test every time a file changed.

Webpack 5.x.x changes

Update to support webpack 5.x.x, some modules require in the webpack config for this to work :-

  • path-browserify
  • stream-browserify
  • process/browser

Usage

 var WebpackTapeRun = require('webpack-tape-run')

new WebpackTapeRun(opts)
  • opts.tapeRun: (object) optional tape-run options.
  • opts.reporter: (string) optional reporter options.
 module.exports = {
  entry: './test',
  mode: 'development',
  output: {
    path: path.resolve(__dirname, './output'),
    filename: 'test.js'
  },
  resolve: {
    modules: ['node_modules'],
    extensions: ['*', '.js'],
    fallback: {
      fs: false,
      buffer: false,
      path: require.resolve('path-browserify'),
      stream: require.resolve('stream-browserify')
    }
  },
  target: 'web',
  plugins: [
    new webpack.ProvidePlugin({
      process: 'process/browser'
    }),
    new WebpackTapeRun({
      tapeRun: {
       browser: 'phantomjs'
      },
      reporter: 'tap-spec'
    })
  ]
}

By default, output is pipe to process.stdout. You can specify a reporter as an option for the output,
if you using coverify, you also need transform-loader in
the webpack.config.js, check this for a working example

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code