DEV Community

Rickvian Aldi
Rickvian Aldi

Posted on

Run Leetcode locally - Javascript test case for practices

Leetcode debugging feature sits behind paywall.
Stop paying for that!

I once wish i could just use VScode
and leverage some of the debugging feature
you can do that easily, but how about the test cases?

Thats why i collect build my own playground repo to practice solving Leetcode Javascript.
I decided it has enough tests, so i open sourced it, check it out!

Tip: use Jest/Vitest runner extension in VScode, clicking debug will attach debugger on the specific case

I find debug mode is the most useful feature to figure out where i did mistake during practice.

https://lnkd.in/gW34BMp9

So far i cover blind 75 list, will add top 150 later, and gradually covering 3K questions

How to use this repo

  • Clone this repo

  • run npm install

this repo contains practice problem playground you can run under

leetcode-playground/
└── /[problemsname].js
open the .js file, you can start exercise of solving problem.

Run test
every problem has respective test case you can run using `Vitest
It contains test scenarios ready to battle test your solution (You can contribute test case!)
Tests grouped under /tests folder.

Tips for debugging
To assist your learning, debugging mode is useful to understand why your code does not work,
you can attach breakpoint, and run test in debug mode.
I personally use VScode extension "Jest/ Vitest runner by firsttris". When you open the file, simply click 'debug' to run specific test or describe block. it will run your test in debug mode.

Top comments (0)