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

qunit-migrate

v2.0.2

Published

Migrate old QUnit code to 2.x

Downloads

20

Readme

QUnit Migrate

NPM Version Build Status

Migrate old QUnit code to 2.x.

Features

  • JSCS support
  • Custom config support for defining rules
  • Supports conversion of Async tests
  • Support for globbing patterns
  • Both regex and ast parser supported

Install

npm install --global qunit-migrate

Usage

  qunit-migrate -h

  Usage: qunit-migrate [options] <file ...>

  QUnit Migrate: A tool to migrate your files to QUnit 2.0 API

  Options:

    -h, --help                output usage information
    -V, --version             output the version number
    -c, --config <path>       Config file for qunit-migrate
    -P, --parser <regex|ast>  Parser to be used for parsing, Default: ast
    -w, --write               Pass if parsed files should be overwritten. Default: false
    -p, --preset <string>     Preset rule for jscs config. Default: jquery
    -j, --no-jscs             Pass if jscs fix should not be applied. Default: true

  Globbing is supported in files

  Examples:

    $ qunit-migrate "./**/*.js" -w --preset "google" -c "config.json"
    $ # This will migrate all js files in subdirectories using google
    $ # preset and config as config.json

Information: AST parser is more robust than regex parser

Configuration

Various rules can be toggled through use of custom config which can be passed via -c option.

Default config file

Sample config file

Config Rules

Example:

qunit-migrate tries to change old QUnit code to new QUnit specifications.

For e.g. following code will be converted as follows:

// Taken directly from jquery-globalize
// file1.js
define([
  "cldr",
  "src/core",
  "json!cldr-data/supplemental/likelySubtags.json",
  "cldr/event"
], function( Cldr, Globalize, likelySubtags ) {
Cldr.load( likelySubtags );
module( "Globalize.locale" );
ssyncTest( "should allow String locale", function() {
  stop();
  Globalize.locale( "en" );
  ok( Globalize.cldr instanceof Cldr );
  equal( Globalize.cldr.locale, "en" );
  start();
});
});

$ qunit-migrate "file1.js" -w

to

// Taken directly from jquery-globalize
// file1.js
define( [ 
  "qunit",
  "cldr",
  "src/core",
  "json!cldr-data/supplemental/likelySubtags.json",
  "cldr/event"
], function( QUnit, Cldr, Globalize, likelySubtags ) {
Cldr.load( likelySubtags );
QUnit.module( "Globalize.locale" );
QUnit.test( "should allow String locale", function( assert ) {
  var ready = assert.async();
  Globalize.locale( "en" );
  assert.ok( Globalize.cldr instanceof Cldr );
  assert.equal( Globalize.cldr.locale, "en" );
  ready();
});
});

API

$ npm install --save qunit-migrate

var qunitMigrate = require('qunit-migrate');
var qmAst = qunitMigrate.ast;
var qmRegex = qunitMigrate.regex;
var data = 'Some old qunit code';

var modifiedDataAST = qmAst(data); // Fixed code through AST
var modifiedDataRegex = qmRegex(data); // Fixed code through AST

Information: qunit-migrate api doesn't fix source with jscs

Accuracy & Limitations

QUnit migrate tries its best to upgrade your API, but there are still some limitations.

For e.g.

  • If you are encapsulating some of your logic in a function and using assertions in that, it is your responsibility to pass assert into function parameters. API of qunit-migrate can also be upgraded to do this, but it doesn't support it at the moment
  • There might be issues with require definitions some time if they are not in the start and encapsulated somewhere.
  • QUnit.reset is not supported as of now

All these are fixable through AST. Pull requests are welcome

License

MIT © Amanpreet Singh