npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tap-webpack-plugin

v2.0.0

Published

Run TAP tests on every compile with webpack

Downloads

50

Readme

tap-webpack-plugin

travis js-standard-style npm

Run TAP tests on every compile with webpack

This is a plugin for webpack that runs the generated output bundle with Node.js and parses the output as TAP. This works well with webpack --watch as it will run your tests every time a file changes.

Note: You should use the target: 'node' option in your webpack configuration as the generated output will be run with Node.js.

Using a TAP Reporter

By default this plugin will parse the TAP output and report any errors from the TAP output to webpack. If instead you want to pass the TAP output to a TAP reporter, just use the reporter option, like this:

new TapWebpackPlugin({ reporter: 'tap-spec' })

The reporter option specifies the command line for the reporter. It will be run in a shell, so you can pass arguments such as 'tap-spec --no-color'. Output from the TAP reporter will be written directly to the stdout of the webpack process. If the TAP reporter command exits with a non-zero exit code, the plugin will report an error to webpack.

Example

// Your webpack.config.js
var TapWebpackPlugin = require('tap-webpack-plugin')

module.exports = {
  target: 'node',

  entry: ['./test'],

  output: {
    path: 'output',
    filename: 'test.js'
  },

  plugins: [
    new TapWebpackPlugin(),

    // or with a reporter:
    new TapWebpackPlugin({ reporter: 'tap-spec' })
  ]
}
// test.js
var test = require('tape')

test('successful test', function (t) {
  t.equal(1, 1)
  t.end()
})

Example App

You can also generate your main application bundle and a test bundle by exporting an array of configuration objects in the webpack.config.js:

// Your webpack.config.js
var TapWebpackPlugin = require('tap-webpack-plugin')

module.exports = [
  // main bundle configuration
  {
    entry: ['./main'],
    output: {
      path: 'output/dist',
      filename: 'main.js'
    }
  },

  // test bundle configuration
  {
    target: 'node',

    entry: ['./test'],

    output: {
      path: 'output',
      filename: 'test.js'
    },

    plugins: [
      new TapWebpackPlugin()
    ]
  }
];

Then run webpack just like normal and your main bundle will be generated and your tests will be compiled and run, all in one command!