npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

citeproc-test-runner

v1.1.116

Published

CSL test runner with style support

Downloads

293

Readme

Citeproc Test Runner (CTR for short) is a productivity tool for maintaining citation styles in the popular Citation Style Language (CSL) used by Zotero, Mendeley, Jurism and other projects. The script assumes that node, java and mocha are installed (the last globally with npm i -g mocha). With those in place, installation is a one-liner:

    npm install -g citeproc-test-runner

After installation, starting the program with cslrun will spit out instructions pointing back to this document. The remaining steps for setup are explained below. The instructions assume that you have a GitHub account (if you don't yet have an account, you should create a free account now).

Setting up

Joining the test items library

CTR can build tests for individual styles, using items from a shared public library. As a first step, visit the "Jurism Test Submissions" library (below), join it, and then sync Jurism or Zotero to add the library to your local client:

    https://www.zotero.org/groups/2339078/jurism_test_submissions

Note: Earlier versions of cslrun were set to use a different library.

Adding a collection of style items

Tests are identified to a style using its slug name, which is the last portion of the style's CSL id string. For example, the slug name of the style http://www.zotero.org/styles/cell is cell.

Tests are written into and run from a local style tests directory. To facilitate the sharing of tests among maintainers, this directory should be a clone of your personal fork of the jm-style-tests repository on GitHub:

    <visit https://github.com/Juris-M/jm-style-tests and fork the repository>
    git clone https://github.com/my-github-name/jm-style-tests.git

This allows style maintainers to quickly confirm that changes subsequently made to the style do not have unwanted side effects. §

After cloning your fork of the tests repository, set the path to it in the CTR configuration file, located in the user home directory ~/.cslrun.yaml:

groupID: 2319948
path:
  styletests: /path/to/jm-style-tests
  local: false
  std: false
  src: false
  locale: false
  abbrevs: false
  modules: false
  cslschema: false
  cslmschema: false

By default, CTR builds tests from Jurism Style Test Items, a public group library (to use a different source library, set its id as the groupID value in ~/.cslrun.yaml). To make items available for a given style, join the group and create a top-level collection with the slug name of the style, and add some items to the collection. It is helpful to write a short description of the item to be tests (i.e. within 30 characters or so) into the Abstract field.

To build tests, use cslrun with the -w option to set the style to be tested, and the -U option to update test fixtures from the group library:

    cslrun -w /path/to/cell.csl -U

This will write test fixtures to a subdirectory of the style tests directory, named for the slug name of the style (if the subdirectory does not exist, it will be created). Finish the tests by using cslrun with the a option to run all tests, and the -k option to confirm output:

    cslrun -w /path/to/cell.csl -a -k

With the -k option, cslrun will show the style output as a failed test, prompting for confirmation that the output is correct. If Y is selected for each failing fixture, all tests will pass. Use ctrl-c to exit cslrun and return to the command line.

To share the tests. check them in and push them to your jm-style-tests repository on GitHub:

    cd /path/to/jm-style-tests
    git commit -m "Add tests for cell" -a
    git push

Then jump to GitHub and file a pull request to the main jm-style-tests project to have your tests added to the suite.

That's pretty much it. You can rerun the tests against the style anytime. If the -k option is omitted, cslrun will simply watch the CSL file, revalidating it and rerunning all tests whenever it is saved, to convert any plain text editor into a poorman's CSL IDE:

    cslrun -w /path/to/cell.csl -a

A few other options are available on CTR. See cslrun -h for further details.

Test layout

CTR works from tests written in the idiosyncratic CSL test format, documented in the CSL test-suite repository. The description there is for the self-contained tests used in the processor test suite, and the tests generated by CTR (see below) differ in a few respects. Specifically: CTR style tests omit the CSL section (because they use CSL code directly from the style); they include a KEYS array to memo the source of the input data; and they use a MODE of "all" to exercise the various forms that a citation may have in all contexts.


Enjoy!

FB