1.1.0 • Published 4 years ago

generator-hackerrank v1.1.0

Weekly downloads
6
License
MIT
Repository
github
Last release
4 years ago

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

1.1.0

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago