Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

HyperMD Test Suites

Running Test

  1. Run node tools/prepare
  2. Start HTTP server on HyperMD project directory.
  3. Open http://localhost:xxxx/test/.
    • Optionally, add ?cases=foo/*,bar/baz ... to choose test cases to run
  4. Once finished, the title of window will change.
    • If a test task failed, its detail will presents on the page.

Create a Test

Let's say the test is abc/foobar. Create abc/foobar.ts in src dir and write out:

import { Test } from "hypermd_test/tester";

export const test = new Test('FooBar of ABC')

test.add('Feature1', (out) => {
  return true; // feature1 test pass
})

test.add('Feature2', (out) => {
  out.detail = "Seems feature2 not implemented."; // <- `detail` can be a string, Error, JSON-able object, or HTMLElement
  return false; // feature2 failed.
})

test.add('Feature3', (out) => {
  throw new Error("Hell no! Feature3 Failed!") // <- `out.detail` will be replaced by this Error object
})

test.add('Feature4 (Async)', async (out) => { // <- async task function is supported
  const value = await get_answer_to_unverse();
  return value == 42;
})