The general process of “smoke test” for webpack packaged projects with mocha


Step 1: delete the ‘. / dist’ directory before packaging starts
rimraf(‘./dist’, () => {

constprodConfig = require('../../lib/')
webpack(prodConfig, (err, stats) \=> {
if (err) { 




//Step 3: add the test rules to the package
mocha.addFile(resolve(\_\_dirname, './html-test.js'))
mocha.addFile(resolve(\_\_dirname, './css-js-test.js'))


Step 2: create a new test rule

const glob = require('glob');
describe('Checking generated html files',() \=> {
    it('should generate html files', (done) \=> {
    constfiles = glob.sync('./dist/+(index|search).html')
    if (files.length) {
    } else {
        thrownewError('no html files generated')

Tip: About glob.sync (3) special description of the method:

  • pattern {String}: match pattern.
  • options {Object}
  • return: {Array<String>}: matches the file name in the pattern.

This pattern is a string,It’s not regularIt has its own matching rules, such as:
Instead, it is written as follows:
If you can’t agree with each other, you must distinguish them
For details, please move here:…

Recommended Today

Construction of Vue development environment and project creation under mac

start First of all, let’s take a look at the overall development environment of Vue. Homebrew: package manager under MAC system, similar to apt get under Linux, windows control panel – install and remove program Node.jsJavaScript runtime, which is similar to simultaneous interpretation in international conferences, can’t run various programming languages directly between different systems […]