Skip to content

A code runner, which uses the Tape framework, that allows an individual student to check the correctness of his/her JavaScript codes on CLI.

License

Notifications You must be signed in to change notification settings

The-Last-Mile-JS/code-runner-student

Repository files navigation

Code Runner (Student)

Build Status License: MIT Open Source Love
A code runner, which uses the Tape.js unit-testing framework, that allows an individual student to check the correctness of his/her codes on the Command Line Interface (CLI).

Table of Content

How It Works

The mainFunc (where the students write the function solution) in the module.exports object and the unit tests are passed into the Tape.js driver "code_runner/code_runner.js". The driver runs the mainFunc against the unit tests, and the output of the unit-testing is formatted by "code_runner/tap.js" before it is displayed on the Command Line Interface.

System

Dependencies

Ensure that the below dependencies are installed through npm.

  • tape.js (v4.9): tap-producing test harness for node and browsers
  • cli-color (v1.2): Formatting for the console output.

Setup (Admin)

Inclusion of Code Runner into Problem Folder

Inside the problem folder, there should be four files:

  1. problem.js: Contains the problem and empty space for student's codes
  2. code_runner/code_runner.js: Driver of unit-tests
  3. code_runner/tap.js: Used for formatting the result in the command line
  4. code_runner/unit_test.js: Unit tests for students' codes

What to Modify?

  1. code_runner/unit_test.js: Change the description of the unit tests, test cases and the expected results in the module.exports object.
  2. code_runner/code_runner.js: Depending on the test cases (arguments) and the expected results, modify the line that equates expected answers to student code's output t.equal(unitTest.answers[index], student.mainFunc(unitTest.testCases[index][0], unitTest.testCases[index][1]));.

Usage (Student)

Commands

After writing the codes in the "problem.js" file, entering the directory code_runner and calling node tap.js code_runner.js on his command line, the student will see the report in his CLI.
Output

Customizing Unit Tests

The student can go to "code_runner/unit_test.js" and modify two fields of module.exports object:

  1. test cases in the testCases field
  2. expected outputs in the answers field

About

A code runner, which uses the Tape framework, that allows an individual student to check the correctness of his/her JavaScript codes on CLI.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published