What is the best method for testing different versions of the same module simultaneously?

My goal is to distribute a module across various component manager systems like npmjs and bower. I also want to provide downloadable builds in different styles such as AMD for requirejs, commonJS, and a global namespace version for browsers - all minified. This amounts to more than 10 different builds.

Currently, I have an AMD build along with unit tests written using karma, jasmine, and requirejs in an AMD style. I am seeking advice on how to generate the other builds as well as write tests for them.

I am unsure about the base of transformations required for each build. Each output package has a common part and a package-specific part.

In terms of AMD - requirejs (uncertain about the config options)

define(["module", "dependency"], function (module, dependency) {
    var m = {
        config: function (options){
            //...
        },
        //...
        //do something with the dependency
    };

    m.config(module.config()); //load config options set by require.config()
    return m;
});

For commonJS

var dependency = require("dependency");
module.exports = {
    config: function (options){
        //...
    },
    //...
    //do something with the dependency
};

When it comes to the global version

var m = (function (){
    return {
        config: function (options){
            //...
        },
        //...
        //do something with the dependency
    };
})(dependency);

I'm torn between developing a common codebase and building it before every test, or developing one specific package, testing it, and then transforming it into the other builds?

I plan on using gulp to automate the creation of builds and run unit tests before publishing. Additionally, I would like an automatic version number update feature. Do you think running unit tests after the build process is necessary to ensure bug-free code is published?

Answer №1

There are various transformation libraries available for gulp:

Transforming between different package formats is simple using these tools along with thorough testing. Commonjs can be tested with node and jasmine-node, standard js with karma and jasmine, and amd with karma, requirejs, and jasmine.

It is not recommended to create a generic descriptor and convert it before every test. Avoid introducing new languages like coffeescript, instead focus on converting between existing packages.

Running unit tests prior to publishing is advisable. With only three common package types, these libraries will suffice for all component management tasks.

The approach to versioning is undecided at this time. While manual setting is easy, exploring systems such as Travis or Maven may offer more benefits. Updates will be made to this answer once a decision is reached.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Trigger Element Upon Click

Forgive me in advance for the lack of quality in this question, but I'll proceed anyway: All I want is for an element to slide open when clicked with a mouse! That's all! More specifically, I am looking for a single menu item that, upon clickin ...

When importing a module, the function in the ts file may not be recognized or located

While attempting to create a VSTS (Azure Devops) Extension, I encountered a perplexing issue. Within my HTML page, I have a button element with an onclick listener: <!DOCTYPE html> <head> <script type="text/javascript"> VS ...

Node.js / Gulp fails to transfer all files to the 'dist' directory

Despite my efforts, Gulp is only copying half of the sub-folders and files to the dist directory. Some folders are being ignored even after trying different solutions like renaming them without special characters or ensuring the same subfolder structure as ...

Model of Objects within a Document

Here's a puzzling question for you: why does console.log(document.body) and console.log(document.head) work perfectly fine, but console.log(document.script) or console.log(document.html) don't seem to do anything? It's strange because all of ...

The maxBodySize feature is ineffective in restify

I am currently running a node app on version v0.10.33 with the Restify module ^2.8.3 installed. var app = restify.createServer(); app.use(restify.queryParser()); app.use(restify.bodyParser({ maxBodySize: 1, //Issue: The limit is not being enforced at th ...

An error stating that "DataTable is not a recognized function" occurred within the document function

Previously, I set up datatables using the code below: $(function () { $('#keywords-table').DataTable({ "ajax": ({ url: "{{ route('getKeywordsByProductId') }}", method: "get", ...

Guide to dynamically add tr element using CSS to a table

While using the $.each function in jQuery, I am retrieving data and adding it to a table in the following manner: $.each(segment, function (index, innerSegment) { var tr; tr = $('<tr/>'); tr.append("<td>" + segment[i].Airline.Air ...

Is it possible to incorporate additional sections by utilizing map and props in the given code snippet?

I have a component named CardItems.jsx which specifically defines the appearance of a card. Then, I also have Gotocart.jsx where there is a welcome section (similar to welcoming someone to their cart) and an order section at the end (for initiating an orde ...

The input value does not update in the controller when using AngularJS ng-model

Why is it that when I print out console.log($scope.inputvalue), the variable does not update with the values I enter in the input field? Did I misunderstand the purpose of ng-model? If so, how can I pass a value from the view to the controller? (functi ...

Python data type unit test results in failure due to unexpected values: Expected 'NaT' but instead received 'NaN'

Currently, I am initiating unit-testing for my python data pipeline by utilizing the unittest module. An example of a Data class object: class IsAvailable(Object) employee_id: int = Property() start_time: str = Property() Here is a sample unit t ...

Guide to configuring a robust schema and validation with joi

Currently in the process of setting up validation using the joi package, encountering syntax-related issues along the way. The schema in place is simple, checking for a valid number and verifying if the ID exists in the database. export default router.pos ...

The cookies() function in NextJS triggers a page refresh, while trpc consistently fetches the entire route

Is it expected for a cookies().set() function call to trigger a full page refresh in the new Next 14 version? I have a chart component that fetches new data at every interval change, which was working fine when fetching the data server-side. However, since ...

Tips for adjusting the value of a textbox up and down

I am facing an issue with my booking flight form that is supposed to take input from users regarding the number of travelers. I have three textboxes for Adult, Children, and Infants respectively, along with a main textbox to display the final result. Howev ...

Utilizing Jquery to interchange two values and update styling

I am looking to create a script that allows me to select a black div by clicking on it (turning it red), and then transfer the value from the black div into a white div with another click. The functionality works as expected when swapping values between tw ...

Consecutive POST requests in Angular 4

Can you assist me with making sequential (synchronous) http POST calls that wait for the response from each call? generateDoc(project, Item, language, isDOCXFormat) : Observable<any> { return this.http.post(this.sessionStorageService.retriev ...

Having trouble with $(document).ready not functioning correctly?

After following the instructions to move my jQuery CDN to the bottom of the page, I encountered a problem. The script below was functioning perfectly when my jquery files were at the top of the page: if ($(window).width() >= 768) { $('.col-l ...

Is there a glitch preventing the connection between HTML and CSS in Notepad++ even though the link is correct?

I have encountered a puzzling situation that has left me scratching my head in confusion. Despite being a rookie, I've had experience with linking CSS files before and can't understand why it's not working this time around. This issue is per ...

Issues with Alignment of Navbar Elements in Bootstrap 3

When I test my website locally, the elements are aligned correctly as expected. However, when I view it on my live webpage, the elements are all left-aligned. I've attempted a solution from this source, but the issue persists. What confuses me is why ...

Is it feasible to obtain multiple tag-name indexes using JavaScript?

Exploring the table search function provided by W3Schools has brought up an interesting question in my mind. Is it feasible to simultaneously retrieve multiple indexes using getElementsByTagName and conduct a search across the entire table instead of just ...

The toggle-input component I implemented in React is not providing the desired level of accessibility

Having an accessibility issue with a toggle input while using VoiceOver on a Mac. The problem is that when I turn the toggle off, VoiceOver says it's on, and vice versa. How can I fix this so that VoiceOver accurately states whether the toggle is on o ...