w3c / scribejs

Converter of RRSAgent IRC logs into minutes in markdown
https://w3c.github.io/scribejs/BrowserView/
Other
11 stars 14 forks source link

Write a test suite and set up Travis CI #26

Closed tripu closed 7 years ago

tripu commented 7 years ago

test/test.js is a test suite to be run with Mocha (added as a devDependency): it checks a few simple things (Node.js is present, invoking scribejs w/o params produces an error), and then tests the CLI in a couple scenarios (local log file, local output).

It's a beginning. Some important bugs will be captured by this test suite as it is now (some JS syntax errors; some missing packages; some uncaught exceptions; some errors reading a local log, producing Markdown, or dumping the result to a local file, etc). But more comprehensive testing is desirable; eg, uploading to GH, testing as a CGI script, etc. See comments [TODO] at the end of the file.

Output example:

$ npm test

> scribejs@0.10.0 test /home/travis/build/w3c/scribejs
> mocha

  Basics
    Node.js
      ✓ exists (166ms)
    scribejs
      ✓ returns an error with no params (159ms)
      ✓ dumps help with “-h” (144ms)

  CLI usage
    ✓ can read log from a local file (278ms)
    ✓ can dump result to a local file (256ms)

  5 passing (1s)

Travis CI is set up and doing builds now with versions of Node.js 6 and 8. New branches and PRs will be tested automatically.

The Travis script, .travis.yml, also invokes nsp to check for known vulnerabilities in the versions of npm packages we're using (nsp added as a devDependency).

README updated.

Fixes #8.

iherman commented 7 years ago

@tripu it seems that another accepted PR conflicts with this one; can you check what they are?

iherman commented 7 years ago

I would also like some more explanation on what exactly happens when used. Never used this before...

tripu commented 7 years ago

@iherman:

“It seems that another accepted PR conflicts with this one; can you check what they are?”

I've rebased this branch against master, and fixed that conflict.

“I would also like some more explanation on what exactly happens when used. Never used this before...”

Mocha is a test framework for JS. When invoked, it by default looks for the file test/test.js that I added here. There are different approaches to testing, but in general it consists of assertions about values or states of the program; examine the file to see what I did there. You can invoke mocha from the command line; in this case I also added an npm script for that.

Travis CI is a tool for continuous integration. The file .travis.yml sets up this GH project on Travis. Travis can “build” the project (by installing dependencies, checking stuff, running test suites that have been configured, etc) for each commit, branch and/or PR here. The results are then available on PR pages (like this one; click “show all checks”). Or on this other PR (click “view details”, then “details”)