Skip to content

Webpack + external files issue. #152

@WRidder

Description

@WRidder

I would like to add wallabyjs support to a project of mine consisting of a Backgrid plugin

Construction is somewhat as follows:

  • src file is packed using webpack (it requires jquery, backbone, backgrid and underscore)
  • the plugin adds an attribute (Backgrid.extension.ColumnManager) to the existing backgrid instance

However, when loading the tests using wallabyjs the plugin isn't added to the existing backgrid object.

Configuration
wallaby.js

var wallabyWebpack = require('wallaby-webpack');
var webpackConfig = require('./config/webpack.wallaby');
var webpackPostprocessor = wallabyWebpack(webpackConfig);

module.exports = function () {
    return {
        files: [
            {
                pattern: "node_modules/jquery/dist/jquery.min.js",
                instrument: false
            },
            {
                pattern: "node_modules/underscore/underscore-min.js",
                instrument: false
            },
            {
                pattern: "node_modules/backbone/backbone-min.js",
                instrument: false
            },
            {
                pattern: "node_modules/backgrid/lib/backgrid.js",
                instrument: false
            },
            {
                pattern: "src/*.js",
                load: false
            }
        ],

        tests: [
            {
                pattern: 'test/*.js',
                load: false
            }
        ],
        //debug: true,
        postprocessor: webpackPostprocessor,
        bootstrap: function () {
            // Backgrid/jquery etc are available here if a console.log is used.
            window.__moduleBundler.loadTests();
        }
    }
};

webpack.wallaby.js

"use strict";
var webpack = require("webpack");

module.exports = function() {
  return {
    externals: {
        "jquery": "jQuery",
        "backbone": "Backbone",
        "underscore": "_",
        "backgrid": "Backgrid"
    }
  };
};

Part of wallaby.js output:

22 failing tests, 0 passing

test/test.js Backgrid.Extension.ColumnManager - Visibility management uses the given columns [3 ms]

    TypeError: 'undefined' is not an object (evaluating 'Backgrid.Extension.ColumnManager.prototype')
        at test/test.js:35

This basically means that the plugin doesn't register itself to the Backgrid object. However; does this maybe have to do with the order in which files are loaded?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions