An open API service indexing awesome lists of open source software.

https://github.com/naufal-yafi/solve-code-hackerrank

Push Rank
https://github.com/naufal-yafi/solve-code-hackerrank

algorithm-challenges algorithms challenge javascript

Last synced: 7 months ago
JSON representation

Push Rank

Awesome Lists containing this project

README

          

![contributor](https://img.shields.io/github/contributors/naufal-yafi/solve-code-hackerrank?color=red) ![size](https://img.shields.io/github/repo-size/naufal-yafi/solve-code-hackerrank) ![commit](https://img.shields.io/github/last-commit/naufal-yafi/solve-code-hackerrank)

πŸ§‘β€πŸ’»HackerRank

This repo I use to store the code - the code I've already completed. Not only learning the algorithms that HackerRank has provided but also learning to use unit testing from the javascript library, namely Jest. And I'm also using the Babel library because Jest doesn't support ES6 Modules yet so it should be compiled into CommonJS.

⚠️ Previously installed the required dependesy by using the command ⚠️

```sh
npm i
```

How to Use:

You can run the `npm test` command to run all tests. If you want to run a specific test, you can use `npm run test-nameFile`. I've written it in package.json.

```json
"scripts": {
"test": "jest",
"test-solved-me-first": "npx jest --runTestsByPath .solved-codesolved-me-first/solve-me-first.test.js",
"test-simple-array-sum": "npx jest --runTestsByPath .solved-codesimple-array-sum/simple-array-sum.test.js",
"test-compare-the-triplets": "npx jest --runTestsByPath .solved-codecompare-the-triplets/compare-the-triplets.test.js",
......
```

Example:

```sh
$ npm run test-diagonal-difference
```

Output:

```sh
$ npm run test-diagonal-difference

> solve-code-hackerrank@1.0.0 test-diagonal-difference
> npx jest --runTestsByPath ./solved-code/diagonal-difference/diagonal-difference.test.js

PASS solved-code/diagonal-difference/diagonal-difference.test.js
√ test case 0 (2 ms)
√ test case 1 (1 ms)
√ test case 2 (1 ms)
√ test case 3 (1 ms)
√ test case 4
√ test case 5 (1 ms)
√ test case 6 (1 ms)
√ test case 7 (7 ms)
√ test case 8 (5 ms)
√ test case 9 (9 ms)
√ test case 10 (18 ms)

Test Suites: 1 passed, 1 total
Tests: 11 passed, 11 total
Snapshots: 0 total
Time: 0.886 s, estimated 4 s
Ran all test suites within paths "./solved-code/diagonal-difference/diagonal-difference.test.js".
```

Output Run All Tests:

```sh
$ npm test

> solve-code-hackerrank@1.0.0 test
> jest

PASS solved-code/solved-me-first/solve-me-first.test.js
√ test case 0 (21 ms)
√ test case 1 (1 ms)

PASS solved-code/a-very-big-sum/a-very-big-sum.test.js
√ test case 0 (22 ms)

PASS test/test-index.test.js
√ testing (7 ms)

PASS solved-code/simple-array-sum/simple-array-sum.test.js
√ test case 0 (17 ms)

PASS solved-code/compare-the-triplets/compare-the-triplets.test.js
√ test case 0 (4 ms)
√ test case 1 (1 ms)

PASS solved-code/diagonal-difference/diagonal-difference.test.js
√ test case 0 (8 ms)
√ test case 1 (1 ms)
√ test case 2
√ test case 3
√ test case 4
√ test case 5 (1 ms)
√ test case 6 (2 ms)
√ test case 7 (9 ms)
√ test case 8 (3 ms)
√ test case 9 (10 ms)
√ test case 10 (8 ms)

Test Suites: 6 passed, 6 total
Tests: 18 passed, 18 total
Snapshots: 0 total
Time: 3.715 s, estimated 4 s
Ran all test suites.
```