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

y2nw

v0.1.3

Published

Nightwatch tests from Yadda features

Downloads

32

Readme

Yadda2Nightwatch!

Nightwatch is great, but coding such tests is boring:

module.exports = {
  "Demo test Google": function (client) {
    client
      .url("http://www.google.com")
      .waitForElementVisible("body", 1000)
      .assert.title("Google")
      .assert.visible("input[type=text]")
      .setValue("input[type=text]", "nightwatch js")
      .waitForElementVisible("button[name=btnG]", 1000)
      .click("button[name=btnG]")
      .pause(1000)
      .assert.containsText("#main", "Node.js powered End-to-End testing framework")
      .end();
  }
};

I thought, let's convert some tests into Yadda features and such:

Feature: Demo test Google

Scenario: Open Google and search for "nightwatch js"

  Given at GoogleSearchPage
  When I search for "nightwatch js"
  Then should I see "Node.js powered End-to-End testing framework"

Well done, then write some steps for:

SearchEngine testing
====================

You can write any Literate CoffeeScript here.

    class Page
      constructor: (@browser) ->
        @browser
          .url(@url)
          .waitForElementVisible('body', 1000)

    class SearchEnginePage extends Page
      searchFor: (text) ->
        @browser
          .setValue(@search.input, text)
          .click(@search.submit)
          .pause(1000)

      hasFound: (val) ->
        @browser.assert.containsText(@search.output, val)

    class GoogleSearchPage extends SearchEnginePage
      url: 'http://google.com'

      search:
        input: 'input[type=text]'
        submit: 'button[name=btnG]'
        output: '#ires'

    page = null
    pages = { GoogleSearchPage }

Steps are defined as "one or more sentences, ending with any of `.,;`, followed by a blank-line with a function-block below".

Declared sentences MUST start with any uppercase letter or a dollar sign for allowing custom pattern-matchers.

Note that you can define many sentences as you want but will only take a single code-block for.

Example step-block
------------------

This is a label.
And therefore, another label.

    (some_argument) ->

All step-blocks are required to be followed by a function-block.

If not, the code will be appended after the previous (or current) step-block.

      # I'm a comment inside
      fun = ->
        'BAR'

Finally, our testing steps
--------------------------

Given at $pageName.

    (page_object) ->
      PageClass = pages[page_object]
      page = new PageClass @browser

When I search for "$searchQuery".

    (query_for_search) ->
      page.searchFor query_for_search

Then should I see "$searchResult".

    (text_for_result) ->
      page.hasFound text_for_result

That's it.

Library usage

Precompile your tests with the following code:

var y2nw = require('y2nw');

y2nw({
  language: 'English',
  src: __dirname + '/tests',
  dest: __dirname + '/generated'
}, function(err) {
  if (err) {
    console.log(err);
  }

  console.log('OK');
});

Now you can execute the generated tests with Nightwatch or grunt-nightwatch.

Build status

Build Status