Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 11f02cd

Browse files
Add ability to run single test via Test.js (#95)
2 parents 357159f + 6326b9e commit 11f02cd

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ The solutions are located under `/LeetcodeProblems`. Each problem has a test fil
77

88
### Run Tests
99

10-
**Unit tests:** To run all the test run `node Test.js` in the console. To run a specific problem in your console run `node <problem_file_path>` (e.g. `node LeetcodeProblems/Lowest_Common_Ancestor_of_a_Binary_Tree.js`).
10+
**Unit tests:** To run all the test run `node Test.js` in the console. To run a specific problem in your console run `node Test.js <problem_file_path>` (e.g. `node Test.js ./LeetcodeProblemsTests/Algorithms/easy/2Sum_Test.js`).
1111

1212
**Linter:** This repository uses [`es-lint`](https://eslint.org/docs/latest/user-guide/command-line-interface). To run all the tests you would need to install the packages by running `npm install` followed by `npx eslint LeetcodeProblems LeetcodeProblemsTests` which will run the eslint in all problems and tests. You can also use the [flag `--fix`](https://eslint.org/docs/latest/user-guide/command-line-interface#fixing-problems) which will automatically fix some of the errors.
1313

‎Test.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ var solve = (problem) => {
3434
console.log("Solving: " + problem);
3535

3636
const tests = require(problem);
37-
console.log("*"*100);
37+
console.log("*".repeat(100));
3838
if (Object.keys(tests).length == 0) {
3939
console.warn("🔴 The problem " + problem + " doesn't have a test method implemented.\n");
4040
return;
@@ -65,4 +65,10 @@ var loadProblemsFiles = (folder) => {
6565
});
6666
};
6767

68-
test_all();
68+
if (process.argv.length > 2) {
69+
const path = process.argv.pop();
70+
solve(path);
71+
} else {
72+
test_all();
73+
}
74+

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /