Script Valley
Open Source Contribution: A Practical Guide
Code Quality and Testing Standards/Assessment

Practice & Assessment

Test your understanding of Code Quality and Testing Standards

Multiple Choice Questions

5
1

You add a new optional parameter with a default value to an existing public function. Which SemVer component should this change increment?

2

What is the correct use of inline code comments according to documentation best practices?

3

You run npm test with coverage and find your change drops test coverage from 87% to 84%. What should you do?

4

Which tool enforces consistent JavaScript and TypeScript code formatting rather than style rules?

5

You need to understand how a bug occurs in a module you have never seen. What is the most effective first step?

Coding Challenges

1
1

Add Tests and Fix a Bug in a Sample Module

You are given a JavaScript module with three functions: parseDate(str), formatCurrency(amount, currency), and truncateText(text, maxLength). The module has no tests and three known bugs: parseDate returns NaN for valid ISO strings in Safari, formatCurrency does not handle negative amounts, and truncateText does not handle null input. Write a Jest test file with at minimum 8 tests covering normal and edge cases for all three functions. Then fix all three bugs. Input: the provided buggy module file. Output: a test file and a fixed module file. All 8 or more tests must pass. Estimated time: 25-30 minutes.

Medium

Mini Project

1

Code Quality Audit and Improvement PR

Choose a module in an open source project that has low test coverage. Without changing behavior, improve the module code quality: add missing unit tests using the project existing test framework, add or improve JSDoc and docstrings for public functions, fix lint warnings without changing logic, and update any stale inline comments. Package all changes into a single PR with a clear description. The PR must not drop coverage, must pass all existing CI checks, and must not introduce any behavior changes. Document your process in a QUALITY_AUDIT.md with before and after metrics for test coverage and lint warnings.

Hard