Coder Social home page Coder Social logo

test-runner's Introduction

Test Runner

How to Use:

  1. Download the file testrunner.js from this repository
  2. Refer to the file in the <HEAD> of your index.html
  3. Edit testrunner.js to include your own tests by adding an object with the following format:
const yourTestsObject = {

  firstFunctionToTest: [
    {
      description: "It tests to see if firstFunctionToTest works correctly with argument(s) arg1ForTest1.",
      code: () => firstFunctionToTest(arg1ForTest1),
      expected: // the correct output for argument arg1forTest1
    },
    {
      description: "It tests to see if firstFunctionToTest works correctly with argument(s) arg2ForTest1.",
      code: () => firstFunctionToTest(arg2ForTest1),
      expected: // the correct output for argument arg2ForTest1
    },
    // etc.
  ],

  secondFunctionToTest: [
    {
      description: "It tests to see if secondFunctionToTest works correctly with argument(s) arg1ForTest2.",
      code: () => secondFunctionToTest(arg1ForTest2),
      expected: // the correct output for argument arg1forTest2
    },
    // etc.
  ],
  
  // etc.

}
  1. Call runTests(yourTestsObject) in the terminal or within your program. Results are printed to the console.

runTests also returns a boolean indicating whether all tests were passed.

Options

A second argument can be passed to runTests() as follows:

runTests(yourTestsObject, {
  failuresOnly,
  fancy,
  keepConsole
});
option type default description
failuresOnly boolean false Minimal output, only lists failing tests
fancy boolean true Produces fancy CSS-styled console messages
keepConsole boolean false Retains console contents when logging results

test-runner's People

Contributors

eggborne avatar

Watchers

 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.