Giter Site home page Giter Site logo

jjgonecrypto / hounds Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 3.0 452 KB

Release the hounds and smoke test any site. The beasts will follow links and stream any page errors to a pipe of your choice.

License: MIT License

JavaScript 95.54% HTML 4.46%
nightmare stream e2e-tests smoke-tests monkey-test

hounds's Introduction

hounds

Release the hounds and smoke test any site. Sanity check after a large refactor, or plug into your CI tool of choice.

The beasts will follow all links (internal or otherwise) and round up any uncaught page errors. As a seamless unit, they will scour the field for their quarry by spanning out, containing an area, and expanding (breadth-first search).

Uses nightmare to fire up an Electron webkit browser (with optional UI).

npm version GitHub version CircleCI

Usage

npm i hounds

const hounds = require('hounds')

const hunt = hounds.release({ url: 'http://localhost:8080' })
    .on('error', console.error)
    .on('end', process.exit)

const quarry = new Writable({
    objectMode: true,
    write: (chunk, enc, next) => {
        console.dir(chunk)
        next()
    }
})

hunt.pipe(quarry)

To use the built-in stdout writers, you can use hounds.writers.error and hounds.writers.url:

const hunt = hounds.release({
    url: 'http://localhost:8080',
    logTo: hounds.writers.url()
})

hunt.pipe(hounds.writers.error())

To show the Electron UI, with devTools open, and keep both alive, use the following options when releasing the hounds:

{
    url: '...',
    keepAlive: true,
    nightmare: {
        show: true, openDevTools: true
    }
}

Options

  • url base URL to start from
  • keepAlive don't end the stream or the nightmare session when complete (when combined with nightmare.show, allows you to interact with the browser when done).
  • waitAfterLoadedFor The number of milliseconds to wait after each page is loaded before following the next link in the queue
  • maxFollows The maximum number of links to follow and track (the default is Infinity)
  • timeout The number of ms before ending the session. When the timeout is reached, the system will end on the next attempt to read from the queue (Note: this has no use when keepAlive is true). (No default)
  • logTo An optional writable stream that all URLs attempting to be processed will be written to.
  • urlFilter An optional predicate function, taking the current url as a parameter, and returning true or false as to whether or not to include it in the hunt. Second argument of domainFiltered is a bool stating whether or not the host matches (use it if you'd like to include that check in your filter)
  • before and after callbacks receive nightmare instance and if defined, must return it (see examples/preAuth.js)
  • screnshot A function that given the current url, returns the path string of the PNG to save
  • consoleLevel A string corresponding to one of the console logging levels. The default is error. In this way, console events that are not Javascript errors can be reported.
  • nightmare All nightmare 3.0.1 options are supported

Known Issues

  • screenshot with outside domains causes nightmare to hang periodically (ref issue on nightmare)
  • console.errors not currently handled
  • 404s are not currently handled
  • /index.html and / are not treated as the same URL, and are both processed
  • Subdomains (including www) are treated as different hosts
  • unpipe() won't stop the stream from finding results
  • links which are hidden in the page are still detected, could use jQuery's approach as an optional workaround

Examples

npm i hounds
cd node_modules/hounds/examples
npm i

Then try out node . for a basic example based on the test fixtures

hounds-simple

Unleash them on the latest sites from HackerNews via node hackerNews

Or use them against a local site with auth (see examples/preAuth.js)

hounds-preauth

Changelog

  • 0.2.0 Supports a single url with a promise
  • 0.3.0 Stream support (instead of promises)
    • 0.3.1 Migrated to nightmare - 3x faster than Webdriver/Phantom2 and option to open up devTools
    • 0.3.2 Stream usage cleanup
  • 0.4.0 Support to keep the session alive via keepAlive
  • 0.5.0 Handles console errors that occur after DOMContentLoaded (with configurable timeout waitAfterLoadedFor (ms)). Follows links now.
  • 0.6.0 Prevent visiting the same link twice.
  • 0.7.0 Allow max number of links to follow or timeout.
  • 0.8.0 Support for logTo writable stream for URLs processed, and correct error emitting bugfix.
  • 0.9.0 By default, only links within same hostname:port are considered. Override with predicate function urlFilter
  • 0.10.0 urlFilter also receives result of domain check as second argument. Bug fix: no dupes anchors in the one page
  • 1.0.0 before and after callbacks receive nightmare instance and if defined, must return it (see examples/preAuth.js)
  • 1.1.0 Upgrading to nightmare 2.8.1
  • 1.2.0 Upgrading to nightmare 2.10.0
  • 1.2.1 Fixing tests
  • 1.3.0 Exposing the writers
  • 1.4.0 Support for screenshot
  • 1.4.1 prettyjson to regular dependency
  • 1.5.0 Bugfix: before is invoked during the initial run and the system waits until it completes

hounds's People

Contributors

gmishkin avatar greenkeeper[bot] avatar jjgonecrypto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

hounds's Issues

An in-range update of mocha is breaking the build 🚨

Version 3.3.0 of mocha just got published.

Branch Build failing 🚨
Dependency mocha
Current Version 3.2.0
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As mocha is β€œonly” a devDependency of this project it might not break production or downstream projects, but β€œonly” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this πŸ’ͺ

Status Details - ❌ **ci/circleci** Your tests failed on CircleCI [Details](https://circleci.com/gh/justinjmoses/hounds/49?utm_campaign=vcs-integration-link&utm_medium=referral&utm_source=github-build-link)

Release Notes coverave

Thanks to all our contributors, maintainers, sponsors, and users! ❀️

As highlights:

  • We've got coverage now!
  • Testing is looking less flaky \o/.
  • No more nitpicking about "mocha.js" build on PRs.

πŸŽ‰ Enhancements

  • #2659: Adds support for loading reporter from an absolute or relative path (@sul4bh)
  • #2769: Support --inspect-brk on command-line (@igwejk)

πŸ› Fixes

  • #2662: Replace unicode chars w/ hex codes in HTML reporter (@rotemdan)

πŸ” Coverage

πŸ”© Other

Commits

The new version differs by 89 commits0.

  • fb1687e :ship: Release v3.3.0
  • 1943e02 Add Changelog for v3.3.0
  • 861e968 Refactor literal play-icon hex code to a var
  • 1d3c5bc Fix typo in karma.conf.js
  • 9bd9389 Fix spec paths in test HTML files
  • 0a93024 Adds tests for loading reporters w/ relative/absolute paths (#2773)
  • 73929ad Comment special treatment of '+' in URL query parsing
  • e2c9514 Merge pull request #2769 from igwejk/support_inspect_break_in_opts
  • 038c636 Support --inspect-brk on command-line
  • b4ebabd Merge pull request #2727 from lamby/reproducible-build
  • 882347b Please make the build reproducible.
  • a2fc76c Merge pull request #2703 from seppevs/cover_utils_some_fn_with_tests
  • ed61cd0 cover .some() function in utils.js with tests
  • f42cbf4 Merge pull request #2701 from craigtaub/landingSpec
  • 6065242 use stubbed symbol

There are 89 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.