Coder Social home page Coder Social logo

io-digital / gore Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 81 KB

test web applications using a headless chrome instance

License: MIT License

JavaScript 100.00%
chrome chrome-headless node test browser-testing test-runner chrome-instance devtools-domains

gore's Introduction

gore

gore is a simple and mostly unfinished chrome headless test runner using a slightly monkey-patched chrome-remote-interface as the mechanism for controlling the chrome instance.

the test runner is page navigation oriented, meaning that each test case is made up of discrete steps (just async functions) that interact with the page in some way.

every step in a test case besides the final one is allowed to return boolean, string and undefined values allowing you to pass or fail a test early, navigate to a new page, or declare that navigation occurred manually, respectively. the final step of a test is required to return a boolean value to indicate the outcome.

each test case and its constituent steps are executed sequentially.

example

(async function() {
  var gore = require('gore')
  var {suite, runtime} = await gore()
  suite([{
    description: 'run a google search',
    start_at: 'http://google.com',
    steps: [
      async function() {
        await runtime.eval(function() {
          var search_box = document.querySelector('#lst-ib')
          search_box.value = 'kitties'
          search_box.form.submit() // submit the form to trigger a page navigation
                                   // which causes the next step to be executed
        })
        // return nothing (undefined) from this step to
        // indicate that page navigation was implicit
      },
      async function() {
        var title = await runtime.eval(function() {
          return document.title
        })
        var number_of_results = await runtime.eval(function() {
          return document.querySelectorAll('.g').length
        })
        return ( // return a boolean to indicate the test outcome
          title === 'kitties - Google Search' &&
          number_of_results === 10
        )
      }
    ]
  }])
})()

todo

  • the test runner will use chrome canary by default if it is installed
  • better/more documentation
  • investigate SystemInfo domain
  • add more devtools domains and abstractions
  • add more testing runtime statistics and feedback
  • description strings for test steps
  • tests
  • contribution guidelines
  • write weird test cases to learn and improve the limits of the test runner
  • write examples using more devtools domains
  • screenshot capture
  • test case parallelism using multiple chrome instances/tabs?
  • before/after(all) hooks
  • machine readable output formats

legal

"Google" and "Google Chrome" are trademarks held by Alphabet Inc. i am in no way affiliated with these companies and/or their projects.

gore's People

Contributors

skibz avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

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.