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

elves

v0.1.6

Published

avalon.oniui test tool

Downloads

20

Readme

elves

Join the chat at https://gitter.im/ilife5/elves

An easy, lightweight, headless test tool for avalon.oniui。

Based on phantomJs, support mocha chai and jquery

elves

中文文档

Installation

install from npm

Use it as a command line tool.

npm install elves -g

If you only want to use it in a locally nodejs project.

npm install elves --save

Elves depends on Node.js and npm. Also make sure that phantomJs is installed.

Usage

Usage: 

    elves [options]
    elves [options] <config>
    elves [options] <caseUrl>
    elves [options] <caseUrl> <pageUrl>

Options:

    -h, --help                  output usage information
    -v, --version               output the version number
    -r, --remoteServer          take test on remote server
    -c, --configFile <path>     config file path. defaults to test/elves.config
    -a, --assertions <path>     assertions, defaults to chai
    -l, --localServer <string>  config localServer address, defaults to http://localhost:3000
    -g, --group <string>        runs a group of tests
    -t, --test <string>         runs a single test

hello world

First, we set up a page and case.

example/
└── hello world
    ├── helloworld.html
    └── helloworld.js

helloworld.html

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>Hello world</title>
</head>
<body>
    <p>hello world</p>
</body>
</html>

helloworld.js

var expect = chai.expect;

describe("Hello world", function() {
    it("#should contains 'hello world' in the p", function() {
        expect($("p").eq(0).text() == "hello world");
    })
});

Run the test

elves "example/hello world/helloworld.js" "example/hello world/helloworld.html"

The report

  Hello world
    ✓ #should contains 'hello world' in p 


    ✔ 1 test complete (5ms)

cases only

In some scenarios,we just want to test pure javascript cases without a page。We can be achieved through the following ways。

elves "example/case only/index.js"

Elves will open an empty page for running cases.

use config.json

We can also use a config file in test folder.

[
    {
        "caseUrl": "example/hello world/helloworld.js"
    }
]

Run

elves

Then we can get the reports.

simulate events and touch gestures

jQuery is integrated in Elves, and we can use it simulate events and touch gestures.

$("selector").simulate("click"); // event
$("selector").simulate("tap"); // gesture

support events:

  • click
  • mouse(over|out|down|up|move)
  • key(up|down|press)

support gestures(defination refered to [Zepto.js](http://zeptojs.com/#Touch events) and Hammer.js):

  • tap
  • doubleTap
  • press(longTap)
  • swipe & swipe(Right|Left|Up|Down)

testing asynchronous code

It's the same to test with Mocha.Refered to Mocha.js. With elves, you can also delay your assertions.

it("should show press", function(done) {
    container.simulate("press")

    delay(done, function() {
        expect(content.text()).to.equal("press");
    }, 1000);
})

test on remote server

Elves also support test on remote server.

Create case

var expect = chai.expect;

describe("qunar", function() {
    it("#title should be 【去哪儿网】机票查询预订,酒店预订,旅游团购,度假搜索,门票预订-去哪儿网Qunar.com", function() {
        expect(document.title).to.equal("【去哪儿网】机票查询预订,酒店预订,旅游团购,度假搜索,门票预订-去哪儿网Qunar.com")
    });
});

Run

elves "example/remote server/remote server.js" "http://qunar.com" -r

Then we can get the reports.

  qunar
    ✓ #title should be 【去哪儿网】机票查询预订,酒店预订,旅游团购,度假搜索,门票预订-去哪儿网Qunar.com 


    ✔ 1 test complete (6ms)

assertions

Elves support changing assertions, includes chai and expect.

//test with expect
elves -a "expect"

reporters

Elves support changing reporters through change setupOptions

//setupOptions.js
if(typeof pageStatic === "undefined") {
    pageStatic = {};
}

pageStatic.mochaSetupOptions = {
    ui: "bdd",
    reporter: 'list',
    ignoreLeaks: true
};
elves -M setupOptions.js