@buxlabs/gulp-amd-to-before-all

    1.1.0 • Public • Published

    gulp plugin that converts AMD syntax to beforeAll

    Idea

    Running thousands of unit tests might be time consuming. To speed up the start time slightly you might try to use the beforeAll syntax instead of AMD. This way the browser will load the dependencies before the given spec starts instead of loading all of them in the beginning.

    Installation

    npm install @buxlabs/gulp-amd-to-before-all

    Usage

    Convert files with:

    const gulp = require('gulp');
    const converter = require('@buxlabs/gulp-amd-to-before-all');
    
    module.exports = function (options) {
        return gulp.src(options.src)
        .pipe(converter())
        .pipe(gulp.dest(options.dest));
    };

    Example:

    AMD

    define(['backbone'], function (Backbone) {
        'use strict';
    
        describe('Backbone', function () {
            it('is defined', function () {
                expect(Backbone).toBeDefined();
            }); 
        });
    });

    beforeAll

    describe('Backbone', function () {
    
        var Backbone;
        
        beforeAll(function (done) {
            require(["backbone"], function () {
                Backbone = arguments[0];
                done(); 
            });
        });
    
        it('is defined', function () {
            expect(Backbone).toBeDefined();
        }); 
    });

    Install

    npm i @buxlabs/gulp-amd-to-before-all

    DownloadsWeekly Downloads

    8

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • buxlabs-dev
    • emilos