jest-autograding-reporter

0.1.8 • Public • Published

jest-autograding-reporter

A Jest test results processor that formats the results for Gradescope (docs) and writes them out to a file results.json, as Gradescope prefers.

Usage

npm install --save-dev jest-autograding-reporter

In your jest.config.js, add the global teardown to clean up the temp file:

globalTearDown: "jest-autograding-reporter/teardown.js"

In the test file, add the weights:

const w = require('jest-autograding-reporter').weight

// a test that's worth 3 autograder points
test(w(3, "some test"), () => {
  // ...
})

To run the autograder:

jest --testResultsProcessor jest-autograding-reporter

You probably only want to use this when you're running in Gradescope, or testing the autograder locally, but if you wanted it for all your test runs, you can add it to jest.config.js.

Caveats and wonkiness

  • Uses the test names to store the weights; test names have to be unique
  • Check that the total points matches your total autograder points in Gradescope
  • Because Jest does not use the require cache, this stores the weights in a temporary file, which it attempts to clean up using the teardown function.

Readme

Keywords

Package Sidebar

Install

npm i jest-autograding-reporter

Weekly Downloads

2

Version

0.1.8

License

MIT

Unpacked Size

4.79 kB

Total Files

4

Last publish

Collaborators

  • rrcobb