generator-hackerrank

1.1.0 • Public • Published

generator-hackerrank NPM version Build Status Dependency Status

Generate a Javascript template & unit tests for solving another one of those /r/hackerrank challenges

Installation

First, install Yeoman and generator-hackerrank using npm (we assume you have pre-installed node.js).

npm install -g yo
npm install -g generator-hackerrank

Then generate your new project:

yo hackerrank

This will ask for the task scope and name, along with some other options, and produce the following result:

Main file

// {scope}/{task}.js
 
const solve = (n) => {
  // Put your solution here
  return n;
};
 
module.exports = { solve };
 

Unit tests

// {scope}/{task}.test.js
 
const { solve } = require('./task');
 
describe('Sample Task', () => {
  const examples = [
    {
      query: [1, 2, 3],
      answer: 5,
    }
  ];
 
  examples.forEach(({ query, answer }, i) => {
    it(`should solve example ${i}`, () => {
      expect(solve(query)).toEqual(answer);
    });
  });
});
 

License

MIT © Wain-PC

Package Sidebar

Install

npm i generator-hackerrank

Weekly Downloads

5

Version

1.1.0

License

MIT

Unpacked Size

7.71 kB

Total Files

6

Last publish

Collaborators

  • wain-pc