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

stupa

v1.0.7

Published

A javascript test runner that running jasmine on node

Downloads

5

Readme

stupa

A javascript test runner that running jasmine on node

Usage

Stupa is a javascript test runner that help your to run your jasmine specs in node way.

First, install stupa to the global env.

npm install -g stupa

Then, generating the config file.

stupa init

This command will generate a configure file named stupa.conf.js in the currently directory.

stupa.conf.js

module.exports = {
    // Time to wait in milliseconds before a test automatically fails.
    timeout: 5000,

    specs: {
        // A prefix for all spec_files and helpers
        spec_dir: './',
        // The paths of the spec files
        spec_files: [ 'app/spec/*.js' ],
        // The paths of the spec helpers
        helpers: [ 'app/specHelpers/*.js' ]
    },

    /* A collection of javascript jasmine reporter classes
        - Included reporters:
            AppVeyorReporter - POSTs results to AppVeyor when running inside an AppVeyor environment.
            JUnitXmlReporter - Report test results to a file in JUnit XML Report format.
            NUnitXmlReporter - Report test results to a file in NUnit XML Report format.
            TapReporter - Test Anything Protocol, report tests results to console.
            TeamCityReporter - Basic reporter that outputs spec results to for the Teamcity build system.
            TerminalReporter - Logs to a terminal (including colors) with variable verbosity.
        eg:
            reporters: [ 'TapReporter', 'JUnitXmlReporter' ]
        It will set to a terminal reporter if left it empty.
    */
    reporters: [  ]
}

Of course , you can write the config file by hand or copy paste it from another project.

Finally, starting stupa.

stupa start

When starting Stupa, the configuration file path can be passed in as the first argument.

By default, Stupa will look for stupa.conf.js in the current directory.

Of course, you could specify the configurion file by running:

stupa start mySpec.conf.js

Command line arguments

Specify the running file by using --file=path/to/your/spec/file, it will overwrite the spec files config

stupa start mySpec.conf.js --file=app/spec/my.spec.js

--stop-on-failure=true/false stops execution of a spec after the first expectation failure when set to true

stupa start mySpec.conf.js --file=app/spec/my.spec.js --stop-on-failure=true

Bast practice

Using with phantom to make a suite of end to end test case. And, use superagent to test the RESTFUL APIS.

example.spec.js

var phantom = require('phantom');
var agent = require('superagent')
var http = require('http');

describe('A suite of end to end test case - ', function () {
    var server;

    beforeAll(function (done) {
        server = http.createServer(function (req, res) {
            if (req.url === '/html') {
                res.end('<html><head><title>Stupa!</title></head><body>Hello Stupa.</body></html>');
            } else if ('/json') {
                res.writeHead(200, { 'Content-Type': 'application/json' });
                res.end(JSON.stringify({ data: 'hello stupa!' }));
            } else {
                res.end('hi, ' + req.url);
            }
        });
        server.listen(7777, done);
    });
    afterAll(function () {
        server.close();
    });

    it('page should be successfully opened', function (done) {
        phantom.create().then(function (ph) {
            ph.createPage().then(function (page) {
                page.open('http://localhost:7777/html').then(function (status) {
                    page.evaluate(function () {
                        return document.title;
                    }).then(function (title) {
                        expect(status).toEqual('success');
                        expect(title).toEqual('Stupa!');
                        done();
                        ph.exit();
                    })
                })
            })
        })
    });
    it('asynchronous data should be successfully response', function (done) {
        agent.get('http://localhost:7777/json').end(function (err, res) {
            expect(res.statusCode).toEqual(200);
            expect(res.body.data).toEqual('hello stupa!');
            done();
        })
    });
})

Run:

cd to/the/path/of/example.spec.js
npm install -g stupa
npm install phantom@latest superagent@latest
stupa init
stupa start --file=example.spec.js